HN 写作课

工程师们二十年里聊过的写作。

工程师、作家、编辑和创业者在 Hacker News 上聊了二十年“怎么写”:怎么写得清楚、怎么讲好一个故事、技术文档怎么写、小说和出版是怎么回事。这里把其中关于写作与讲故事的帖子挑出来,配上中文导读、可以直接用的写作要点和评论翻译。

从必读开始
  • 2,600+篇关于写作的 HN 讨论

Writing tips

写作锦囊

正在抽一条写作要点…

Essential

必读 30 篇

在讨论库里看全部精选

编辑精选里 HN 讨论最热的 30 篇,每篇都有中文导读和写作要点。

  1. 正在载入…

Archive

讨论库

按发帖年份分布,点柱子筛选。

排序

    About

    这些讨论是怎么挑出来的

    1. 01

      从全量里捞

      读取 Hacker News 自 2006 年以来的全部帖子,用关键词先捞出 40 分以上、可能和写作有关的约 1.1 万篇。

    2. 02

      只留真正讲写作的

      由 AI 逐条判断是否和写作、讲故事、文风、出版有实质关系,剔除“写代码”“编辑器”这类字面撞车,并分进十个类别。

    3. 03

      提炼可用的要点

      为值得读的帖子写中文导读,提炼 2-4 条可以直接用到自己写作里的要点,并精选翻译 HN 高赞评论。内容由 AI 生成,可能有误。

    技术写作与文档2019github.com

    用 Python 生成图表撰写 LaTeX 论文的技巧

    Tips and tricks to write LaTeX papers in with figures generated in Python

    阅读原文 HN 讨论
    183HN 得分
    65条评论
    4条写作要点

    导读

    这是一份 GitHub 上的 LaTeX 论文写作技巧合集,重点讲如何把 Python 生成的图表纳入论文:保存生成命令、统一图表样式、让数据与编译流程联动。对写作者的价值在于,图表是论文叙事的一部分,把图表生产流程脚本化、可复现,能避免截止日前手忙脚乱地改图。

    关键词 LaTeX图表复现科研写作工作流

    可以直接用的写作要点

    1. 01

      把生成每张图的脚本或命令随论文一起保存(甚至注释在 LaTeX 源码旁),保证任何一张图都能一键重跑。

    2. 02

      在生成阶段就用统一配置(如 matplotlib 的 rcParams、seaborn 的 set)锁定字体、配色、尺寸,而不是逐图手动调整。

    3. 03

      图表优先保存为矢量格式(SVG/PDF),后期组合、加标注在 Inkscape 等工具里完成,不必回到原始代码重画。

    4. 04

      把数据更新和论文编译绑定(如 Makefile 或 knitr),让编译时自动带入最新数据,减少版本错位。

    HN 评论精选

    用 knitr/Makefile 把数据到图表的流程自动化,既统一风格又保证数据最新。

    作者建议把生成图表的命令保存在 LaTeX 文件里。我最近改用 knitr,省掉了这层间接:数据直接放进论文仓库,Makefile 里写 `%.tex: graphs/%.Rnw` 再调用 knit 即可。好处正是作者说的那两点——更容易让所有图表保持统一外观,并在编译过程中自动纳入最新数据。

    akshayn查看英文原文

    > We also recommend to save the command used to generate a figure in the LaTeX file An approach I have adopted recently is Knitr[1], so this layer of indirection goes away. With knitr, my data goes directly into the paper repository, and then my Makefile has something like this: %.tex: graphs/%.Rnw Rscript -e "library(knitr); knit('$?')" The nice thing is exactly what the authors recommend: it's much easier to enforce a standard appearance across all the figures, and automatically incorporate more recent data into the paper as part of the compilation process. [1] https://yihui.name/knitr/

    用矢量工具做后期组合与标注,用 seaborn 统一美化,能省掉大量重复劳动。

    补充一点:Inkscape 对做图非常有用。一次存成 SVG,之后想导出什么格式都行,我通常从 Inkscape 导出 PDF 给 pdflatex 用。它对示意图几乎不可或缺,我也常遇到要把已有图组合起来、或加个标签的情况;Inkscape 能导入 PNG,做这些很轻松,不必回原代码重画,也不用为小改动折腾 LaTeX。对 matplotlib 生成的图,强烈推荐再加 seaborn:它是对 matplotlib 的封装,一个 import 加一个 set 命令就能美化图表,也能直接画图,并支持 pandas 的 DataFrame,用更少的力气得到更好看的结果。

    abhgh查看英文原文

    I'd also add that for figures Inkscape is invaluable [1]. Save as svg once, and export it as whatever later. I typically export it to PDF (from within Inkscape) for pdflatex. While its typically indispensable for schematics, I often seem to run into the use case of combining previously generated plots or figures, or adding a label/text. Since Inkscape can import pngs, this is a breeze with it. I don't have to go back to the original code to regenerate plots, or fiddle around with latex to make minor adjustments. For stuff generated via matplotlib, I'd strongly recommend seaborn as an additional library [2]. This is a wrapper over matplotlib. It can prettify plots with just an import and a 'set' command. You can, of course, use it to plot too, and for stuff doable in matplotlib using the seaborn alternative is much easier and looks better with little or no work. And they support pandas dataframes. [1] https://inkscape.org/ [2] https://seaborn.pydata.org/

    让图表与正文同源(tikz/pgfplots),风格统一且高度可定制。

    如果认真想做漂亮的 LaTeX 图表,我强烈推荐 tikz 和 pgf-plots。从 Python 自动生成 tikz 代码很容易(它本来就是给人读写的),图表的各个方面都能方便地定制。我用 tikz 和 pgf 生成自动报告,图表漂亮、易读,效果很成功。有兴趣的话我在 GitHub 上传了一个从两个 numpy 列表生成 XY 图的示例脚本,代码不算好,只是分享给想尝试的人。

    sigurdjs查看英文原文

    If you are serious about making beautiful figures in latex, I would seriously recommend using tikz and pgf-plots. It is quite easy to automatically generate tikz-code from python (after all it is supposed to be read and written by humans) and all aspects of the figure can easily be customized. I have been quite successful in generating automated reports with pretty and easily readable figures using tikz and pgf. If anyone is interested I have uploaded a sample script for generating XY-plots from two numpy lists to github. The code is by no means very good, but I just wanted to share in case anyone wants to try this approach. https://github.com/sigurdjs/python-tikz

    同类还值得读

    1. 编写更好文档的框架

      A Framework for Writing Better Documentation

      这是 Divio 的文档写作框架,把技术文档按「读者的目标」分成四类:教程(学习导向)、操作指南(问题导向)、参考(信息导向)、解释(理解导向)。

      技术写作与文档2021 · 637 分 · 76 评4 条写作要点编辑精选
    2. 写好一份设计文档

      Writing a good design document

      这篇 HN 帖子标题为《Writing a good design document》,主题是如何写好一份设计文档;对写作者来说,它值得作为技术写作和结构化说明文的参照。

      技术写作与文档2025 · 581 分 · 147 评3 条写作要点编辑精选
    3. 技术写作课程

      Technical Writing Courses

      这是 Google 官方免费技术写作课程(两门),讲受众定义、主动语态、短句、文档结构等基础方法。

      技术写作与文档2020 · 571 分 · 73 评4 条写作要点编辑精选
    4. 写出更好的错误信息

      Write better error messages

      这篇帖子讨论如何写出更好的错误信息,评论补充了开发者场景下的具体做法和真实反面案例。

      技术写作与文档2022 · 566 分 · 253 评4 条写作要点编辑精选
    5. 写一本技术书的经济账

      The Economics of Writing a Technical Book

      一位技术书作者拆解写书的真实经济账:版税收入往往远低于投入的时间成本。

      技术写作与文档2018 · 519 分 · 149 评4 条写作要点编辑精选

    打赏支持

    打赏二维码

    觉得有用,请作者喝杯咖啡。

    WeChat

    关注向阳乔木

    微信公众号「向阳乔木推荐看」

    微信公众号「向阳乔木推荐看」二维码

    微信扫一扫;在微信里打开本页时,长按二维码识别。