AI时代写作与出版新范式的探讨

中国数学会2025年学术年会(山东滨州,2025-10-18)

汤银才

华东师范大学 统计学院

2025-11-18

I. 写作工具的选择:Markdown

目录

  • I. 写作工具的选择:Markdown

  • II. 科技论文写作: \(\TeX\)

  • III. 排校系统的构建: Overleaf

  • IV. 文学化编程: Quarto

  • V. 书稿Quarto模板分享

1.1. 关于写作与出版的思考

如何打造一个高效的(数据科学)写作/出版系统?

目标: 赋能期刊与图书出版

  • 通过Quarto平台

    • 使编程与写作融为一体

    • 建立作者与出版社的桥梁

    • 为读者提供良好的阅读场景

  • 优势

    • 卓越的通用性:支持多种编程语言(如 Python, R, Observable JS)

    • 强大的出版特性:原生支持交叉引用、文献管理、图表排版、代码高亮等科学出版所需的高级功能

  • 多格式出版

    • PDF

    • HTML

    • ePub

  • 丰富的呈现形式

    • 网站、博客

    • 书籍、学术论文、交互式仪表盘

    • 多种格式幻灯片(PPT, Beamer, Revealjs)

起源: 文学化编程

Knuth, 1981提出,用于\(\TeX\)开发

  • 思想

    • 用自然语言(如英语,中文)表达/解释自己思维方式和内在逻辑,而将复杂的代码段或更低层的宏隐藏起来
  • 编程与写作共存 (knitr)

    • 编程(code)

    • 写作(prose)

  • 标准化定制

    • CSS/SCSS 定制

    • \(\TeX\) 定制 . . .

图 1: Doald E. Knuth
图 2: 文学化编程由来

1.2. 写作工具的选择?

AI 时代的写作: 测试AI工具

  • 提示词-1: 简单介绍一下AI时代Quarto优势

  • 提示词-2: 用 Python 语言编写一段代码,要求: 1) 生成1000个标准正态分布随机数,2) 画出其直方图, 3) 叠加一个密度函数,4) 输出为Quarto的代码块

  • 提示词-3: 已经数据\(y_1, \dots, y_n\) 来自正态分布\(N(\mu, \sigma^2)\), 参数\((\mu, \sigma^2)\)的先验分布为\(\pi(\mu, \sigma^2)\propto 1/\sigma^2\), 求感兴趣参数\(\mu\)的边际后验分布.

测试用AI工具(LLMs):

AI写作

AI时代高效的写作:赋能学习、教学、科研与出版

  1. 流行的写作工具

    • Markdown: 码农

    • \(\LaTeX\): 学界

  1. 更高效的写作工具

    • Markdown (写作) + R/Python (编程) + \(\LaTeX\) (出版)
  2. 形成闭环:

    • 兼顾标准化与个性

    • 构建算力平台或出版平台

认识 Markdown

  • 一种轻量级标记语言(使用纯文本格式编写文档),由John Gruber于2004年创建。

  • 语法极其简单,学习成本极低

  • 在与Deepseek, ChatGPT、Claude等大模型交互时,我们需要一种既能表达格式要求,又不会过于复杂的语言。Markdown恰好满足了这一需求. 

# 一级标题
## 二级标题
- 功能特点
  1. 易于学习
  1. 语法简洁
  1. 兼容性好
## 数学公式
$$
x^2+y^2=1
$$
## 黑体与斜体
- *斜体*
- **黑体**
- ***黑斜体***

1.3. Markdown模板

STARF新文速递

  • 用于微信推送

  • 介绍发表论文的主要内容

    • 作者信息(author information)
    • 引用格式(citation)
    • 摘要(abstract)
    • 背景(motivation)
    • 主要结果(main results)
  • 特点:

    • 借助AI工具自动生成初稿
    • 用markdown写作与修改
    • 支持数学公式
    • 输出html
    • 输出pdf

演示示例: STARF新文速递

---
title: "新文速递"
format:
  html:
    theme: 
      light: flatly
      dark: darkly
    toc: true
  pdf:
    pdf-engine: xelatex
    keep-tex: true
    include-in-header: 
      - text: |
            \usepackage{ctex}
            \setlength{\parindent}{0em}
    toc: false
    number-sections: true
    colorlinks: true
---

**新文速递** \| 具有二元结果的随机化临床试验中经协变量调整的无条件治疗效果的稳健方差估计

Robust Variance Estimation for Covariate-Adjusted Unconditional Treatment Effect in Randomized Clinical Trials with Binary Outcomes

**引用**: Ting Ye, Marlena Bannick, Yanyao Yi & Jun Shao (2023), Robust variance estimation for covariate-adjusted unconditional treatment effect in randomized clinical trials with binary outcomes, Statistical Theory and Related Fields, DOI: [10.1080/24754269.2023.2205802](https://doi.org/10.1080/24754269.2023.2205802)

**作者**:

1.  Ting Ye, Department of Biostatistics, University of Washington, USA
2.  Marlena Bannick, Global Statistical Sciences, Eli Lilly and Company, USA
3.  Yanyao Yi, School of Statistics, East China Normal University, China
4.  Jun Shao, Department of Statistics, University of Wisconsin, USA

**摘要**:

为了提高具有二元结果的随机化临床试验中无条件治疗效应估计的精度和检验假设的功效,研究人员和监管机构建议使用g-计算作为协变量调整的可靠方法。然而,g-计算的实际应用由于缺乏可用于不同场合下感兴趣的无条件处理效果的稳健且可显式表示的方差估计公式而受到阻碍。为了填补这一空白,我们为g-计算估计量提供了显式且稳健的方差估计量,并通过模拟证明了其在实际使用中的可行性。

**背景**:

在随机化临床试验中,调整基线协变量被认为是一种提高估计精度和检测治疗效果的方法。2021年5月,美国FDA发布了在随机化临床试验分析中使用协变量的指南草案,并推荐g-计算作为"统计上具有二元结果的无条件治疗效果协变量调整的可靠方法"。然而,(1) 目前没有可用于不同场合感兴趣无条件治疗效果推断的g-计算估计量的稳健且显式表示的方差估计公式;(2) 已有文献(如Ge等,2011) 中关于风险差异和两个治疗组的公式,它是基于模型的,不适合作为模型稳健性推理范式;(3) Ge等(2011)的公式没有考虑到logistic 模型的中由于协变量和非线性而导致的变异性来源,这可能导致置信区间的覆盖概率偏低的情况出现。

考虑有$n$个受试者参与的$k$臂试验($n$个受试者被随机分配到$k$个实验组). 令 $\boldsymbol{A}_i$ 是 $k$ 维处理示性向量,其取值$\boldsymbol{a}_t$表示第$i$个病人接受处理$t$ ($t=1, \ldots, k$), 其第 $t$ 个元素为1,其余元素为0. $Y_i(t), i=1,2,\dots, n, t=1,2,\dots, k$ 是在处理 $t$ 下的二元潜在结果,$\boldsymbol{X}_i$ 是用于调整的基线协变量向量。令 $\theta_t=E\left(Y^{(t)}\right)$, $\boldsymbol{\theta}=\left(\theta_1, \ldots, \theta_k\right)^\top$ (其中省略了个体下标 $i$).

论文考虑的模型为 $E(Y\mid\boldsymbol{A}, \boldsymbol{X})=\operatorname{expit}\left(\boldsymbol{\beta}_A^\top \boldsymbol{A}+\boldsymbol{\beta}_X^\top \boldsymbol{X}\right)$ (称为 logistic 工作模型). $\hat{\mu}_t\left(\boldsymbol{X}_i\right)=\operatorname{expit}\left(\hat{\boldsymbol{\beta}}_A^\top \boldsymbol{a}_t+\hat{\boldsymbol{\beta}}_X^\top \boldsymbol{X}_i\right)$ 为响应变量 $Y$ 在处理 $t$ 下的预测概率,其中$\hat{\boldsymbol{\beta}}_A$ 和 $\hat{\boldsymbol{\beta}}_X$ 分别为 $\boldsymbol{\beta}_A$ 和 $\boldsymbol{\beta}_X$ 的极大似然估计. 则 $\boldsymbol{\theta}$ 的g-计算估计为$\hat{\boldsymbol{\theta}}=\left(\hat{\theta}_1, \ldots, \hat{\theta}_k\right)^\top$,其中 $\hat{\theta}_t=n^{-1} \sum_{i=1}^n \hat{\mu}_t\left(\boldsymbol{X}_i\right)$, 目标参数函数 $f(\boldsymbol{\theta})$ 的g-计算估计为 $\hat{f}(\boldsymbol{\theta})$, 其中 $f(\boldsymbol{\theta})$ 的常用形式有

$$
\begin{aligned}
f(\boldsymbol{\theta})=
\begin{cases}
\theta_t-\theta_s, & (\text{风险差}) \\
\log \frac{\theta_t}{\theta_s}, & (\text{风险比})\\
\log \frac{\theta_t /\left(1-\theta_t\right)}{\theta_s /\left(1-\theta_s\right)},& (\text{优势比})
\end{cases}
\end{aligned}.
$$


论文的目的是要得到 $\hat{f}(\boldsymbol{\theta})$ 的方差的估计.

**主要结果**:

**1. 理论结果**

$\hat{f}(\boldsymbol{\theta})$ 的一致稳健的方差估计为

$$
n^{-1}\{\nabla f(\hat{\boldsymbol{\theta}})\}^T \hat{\boldsymbol{V}}\{\nabla f(\hat{\boldsymbol{\theta}})\},
$$

其中

$$
\hat{\boldsymbol{V}}=\left(\begin{array}{cccc}\hat{v}_{11} & \hat{v}_{12} & \ldots & \hat{v}_{1 k} \\ \vdots & \vdots & \ddots & \vdots \\ \hat{v}_{1 k} & \hat{v}_{2 k} & \ldots & \hat{v}_{k k}\end{array}\right),
$$

$$
\begin{aligned} & \hat{v}_{t t}=\pi_t^{-1} S_{r t}^2+2 Q_{y t t}-S_{\mu t}^2, \quad t=1, \ldots, k, \\ & \hat{v}_{t s}=Q_{y t s}+Q_{y s t}-Q_{\mu t s}, \quad 1 \leq t<s \leq k,\end{aligned},
$$

记号 $S_{r t}^2$, $Q_{y t t}$, $S_{\mu t}^2$,$Q_{y t s}$, $Q_{y s t}$ 和 $Q_{\mu t s}$ 为一些样本方差 (具体见原文).

**2. 模拟结果**

考虑三种情形:

-   情形I: $P(Y=1 \mid \boldsymbol{A}, X)=\operatorname{expit}\left\{-2+5 I\left(\boldsymbol{A}=\boldsymbol{a}_2\right)+X\right\}$, 相应的 $\left(\theta_1, \theta_2\right)=(0.2830,0.8057)$;
-   情形II: $P\left(Y=1 \mid \boldsymbol{A}=\boldsymbol{a}_1, X\right)=\operatorname{expit}(-2+X)$, $P\left(Y=1 \mid \boldsymbol{A}=\boldsymbol{a}_2, X\right)=\operatorname{expit}\left(3+1.5 X-0.01 X^2\right)$, 相应的 $\left(\theta_1, \theta_2\right)=(0.2830,0.7297)$;
-   情形III: $P(Y=1 \mid \boldsymbol{A}, X)=\operatorname{expit}\left(-2+2 I\left(\boldsymbol{A}=\boldsymbol{a}_2\right)+4 I\left(\boldsymbol{A}=\boldsymbol{a}_3\right)+X\right)$, 相应的 $\left(\theta_1, \theta_2, \theta_3\right)=(0.2827,0.5004,0.7172)$.

表1:在情况I-II和简单随机化下,$\hat\theta_2-\hat\theta_1$ 的模拟平均值和标准差(SD),平均标准误差(SE),和 $\theta_2-\theta_1$ 的渐近置信区间的95%覆盖概率(CP).

![](loc-figs/tstf-2023-0011-tab-1.png)

表2:在情况III和简单随机化下,g-计算估计量的均值和标准差(SD),平均标准误差(SE),和基于稳健SE(1)的渐近置信区间的95%覆盖概率(CP).

![](loc-figs/tstf-2023-0011-tab-2.png)

II. 科技论文写作: \(\TeX\)

目录

  • I. 写作工具的选择:Markdown

  • II. 科技论文写作: \(\TeX\)

  • III. 排校系统的构建: Overleaf

  • IV. 文学化编程: Quarto

  • V. 书稿Quarto模板分享

3.1. \(\TeX\) 介绍

认识 \(\TeX\)

  • 最优秀的写作语言, 由Knuth按文学编程设计开发

    • 极致排版质量: 世界上90%以上的书和科技论文都是用 \(\TeX\) 排的
    • 内容与样式(cls/sty)分离
    • 跨版本/跨平台稳定性
  • 平台

  • 推荐编辑器:

    • TeXStudio: 免费、跨平台, 语法高亮显示,支持正向反向搜索
  • 缺点: 学习成本高

使用\(\TeX\)的困扰

  1. 学习曲线陡峭: 需要学习大量专用命令

  2. 排错与调试困难: 错误信息晦涩难懂, 排错过程像“破案”

  3. 编写过程不直观: 非WYSIWYG,需要编译后才能看到最终效果,打断了写作的流畅性

  4. 精细调整复杂: 最头痛的是精确控制图片位置、复杂表格和数学公式

  5. 环境配置繁琐: 不同的发行版本有差异,宏包之间可能产生冲突,定制模板需要极高的技能

  6. 编译速度慢: 带交叉引用的需要编译多次

  7. 协作困难: 需要像Overleaf在线平台支持

  8. 编译方式: 过去常用\(\LaTeX\), pdf\(\LaTeX\), 而现在更倾向于使用Xe\(\LaTeX\)

  9. 编码依赖: 有时GBK无法显示,需要转码为UTF-8

\(\TeX\)编译流程

  1. XeLaTeX
  2. bibtex(由bibtex生成参考文献索引)
  3. XeLaTeX
  4. XeLaTeX

  1. XeLaTeX
  2. biber(由biblatex生成参考文献索引)
  3. XeLaTeX
  4. XeLaTeX

降低学习 \(\TeX\) 的成本

  • 避免复杂的\(\TeX\)命令

    1. 普通用户: 以Markdown为主,少量使用\(\TeX\)命令 (如数学公式)

    2. \(\TeX\)初级用户: \(\TeX\)中通过markdown宏包使用markdown: 减少\(\TeX\)命令的使用1

    3. \(\TeX\)高级用户: 对于特定的任务(如毕业论文,期刊论文),使用高度定制的\(\TeX\)模板

    4. 超级用户: 使用Rmarkdown或quarto模板,构建科研与出版的生态

  • 充分利用Rstudio, VS Code中编辑md, rmd, qmd文件的二种模式:

    • Source (源文件模式)
    • Visual(可视化模式)。
  • AI时代,精通\(\TeX\)似乎并不是必要的

3.2. \(\TeX\)中使用markdown

演示示例: \(\TeX\)中使用markdown

\documentclass[12pt]{article}
\usepackage{markdown}
\usepackage{ctex}
\markdownSetup{hybrid = true}
\begin{document}
\title{示例1}
\maketitle

%\markdownInput{refs/example1.md}
    
\begin{markdown}

```
以 Markdown 撰写文稿,以 LaTeX 排版
```

# 我是 Markdown

这里可以用 Markdown 语法,撰写各种内容。空行表示分段,还可以*强调*,也可以**加粗**,当然也可以***加粗并强调***.

## 这里是二级标题

我还可以使用引用:

> 幸福的获得,在极大的程度上却是由于消除了对自我的过分关注。

## 数学公式

这就是一个行内数学公式 $y=e^x\sin x$,
下面就是一个行间公式
$$\iint_{D} \left(\frac{\partial Q}{\partial x}-\frac{\partial P}{\partial y} \right ) d x d y=\oint_{L } P d x+Q d y$$

\end{markdown}
\end{document}
\documentclass{article}
\usepackage{ctex}
\usepackage[hashEnumerators]{markdown}

\begin{document}

\title{示例2}
\maketitle

%\markdownInput{refs/example2.md}

\begin{markdown}

一级标题用多个双模线
============

无序列表可以这样产生
------------

- 空行表示分段
- *强调*
- **加粗**
- ***加粗并强调***


* 无序列表
* 无序列表
* 无序列表

下面是引用的示例: 

> 幸福的获得,在极大的程度上却是由于消除了对自我的过分关注。

二级标题用多个单横线
------------

有序列表可以这样产生:
-----------------

1. 有序列表 
1. 有序列表
1. 有序列表

还可以借助markdown宏包中的`hashEnumerators`选项这样产生:

#. 有序列表 
#. 有序列表
#. 有序列表

\end{markdown}
\end{document}

3.3. 期刊\(\TeX\)模板

科技期刊论文的基本结构

  1. 标题页

    • 标题
    • 作者,单位
    • 摘要(中英文)
  2. 主体(body)

    • 引言
    • 主要内容
    • 结论与展望
    • 附录
  3. 参考文献

    • bibtex 源文件
    • 编译: biber/biblatex(更灵活), bibtex
  • \(\TeX\) 模板的核心要素: 浮动对象

    • 公式
    • 表格, 图形
    • 文献
    • 定理类对象, 算法
  • \(\TeX\) 模板设计的难点

    • 版芯定制(geometry)
    • 标题页定制(fancyhr或scrlayer-scrpage)
    • 页眉定制: 首页与其余页不同
    • 参考文献的目录与引用格式
    • 元信息的定义(汇总)
    • 编译: 跨平台

《应用概率统计》 \(\TeX\) 模板分享

  • 文档类: apsart.cls

  • 主文件

    • 中文稿: J_APS_CN.tex
    • 英文稿: J_APS_EN.tex
  • 设置文件

    • 中文稿: apsart_CN.cfg
    • 英文稿: apsart_eN.cfg
  • 参考文献

    • 中文稿: apsrefs-cn.bib
    • 中文稿: apsrefs-cn.bib
  • 参考文献的编译方式: biber

  • overleaf模板

  • 1985年创刊,网站
  • 被CSCD,北大核心, 中科院核心等收录
  • 入选数学领域高质量科技期刊分级目录(T3)

《应用概率统计》\(\TeX\)模板文件结构

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{apsart}
\usepackage[headsepline]{scrlayer-scrpage} % 代替fancyhdr
\input{apsart_cn.cfg}                 % 中文稿模板的设置
\usepackage[backend=biber, style=gb7714-2015]{biblatex}
\addbibresource{apsrefs-cn.bib} % 加载bib文件
% (论文信息)
% (作者中英文信息)
% (中英文摘要)
\title{\vspace{-4mm}\zihao{-2}\textbf{\cntitle}
    \!\thanks{~\cnfundinfo}}
\author[1,2]{\cnfirstauthor\thanks{~\corauthorinfo}}
\author[1]{ \cnsecondauthor}
\author[2]{\cnthirdauthor}
\affil[1]{\cnfirstinst}
\affil[2]{\cnsecondinst}

\begin{document}
\maketitle
\thispagestyle{titleheader-online} % print, online
\begin{center}
\begin{minipage}[c]{14cm}
    \zihao{-5}
    \textbf{摘~~~要:}\quad{\fangsong\cnabstract}\\
    \textbf{关键词:}\quad{\fangsong\cnkeywords}\\
    \textbf{中图分类号:}\quad\cnclassno\\
    \rule[3mm]{14cm}{0.2pt}\vskip-4mm
    \textbf{英文引用格式:} 
    \quad \fullcite{Current2024}.
     (in Chinese)\\
    \rule[3mm]{14cm}{0.2pt}
\end{minipage}
\end{center}
\footnote[0]{本文\receivedate{}收到, \modifydate{}收到修改稿, \acceptdate{}录用.}
\pagestyle{mainheader-online} % online, print

\section{引言}
\section{...}
\begin{spacing}{1.2} % 行距
    \setlength{\bibitemsep}{2pt}
    \printbibliography[keyword={cn},resetnumbers=true,
                       title={\bfseries\sffamily \zihao{-4}参考文献}]
\end{spacing}
% (英文摘要)
\end{document}

《统计理论及其应用(英)》\(\TeX\)模板文件结构

\documentclass[]{interact}
\usepackage{epstopdf}% 
% First with apacite style
\usepackage[natbibapa,nodoi]{apacite}%
% 或\usepackage[longnamesfirst,sort]{natbib}% 

\graphicspath{{figs/}}
\begin{document}
\title{...}
\author{
\name{...}
\affil{...}
}
\maketitle

\begin{abstract}
...
\end{abstract}
\begin{keywords}
...
\end{keywords}

\section{Background}
...
\section{...}
\appendix
\section{Appendices}
...
\bibliography{interactapasample}
\bibliographystyle{apacite}
%\bibliographystyle{apalike}

III. 排校系统的构建: Overleaf

目录

  • I. 写作工具的选择:Markdown

  • II. 科技论文写作: \(\TeX\)

  • III. 排校系统的构建: Overleaf

  • IV. 文学化编程: Quarto

  • V. 书稿Quarto模板分享

3.1. Overleaf 介绍

Overleaf: 在线\(\LaTeX\)协作平台

  • 作用

    • 云端\(\TeX\)编辑:无需安装,通过浏览器即可创建、编辑\(\TeX\)文档

    • 协同科研写作:支持多作者实时协作

  • 功能

    • 开箱即用:内置完整\(\LaTeX\)环境(如不同年份的TeXLive)
    • 丰富模板:提供期刊论文、简历、书籍等模板
    • 实时预览与编译:
      • 数学公式在编辑器中实时显示
      • \(\TeX\)源文件与PDF结果同步显示
      • 支持LaTeX/XeLaTeX/LuaLaTeX等引擎
    • 协作工具:在线聊天、版本历史
    • 集成生态:支持GitHub、Zotero、Mendeley、Writefull、TeXGPT等工具

3.2. 基于 Overleaf 协同排校
—以APS为例

协同排校系统构建的要点

  1. 定制高标准的模板: 为期刊创建统一的LaTeX模板(.cls 文件),严格定义文档类型、页面布局、标题字体、章节格式、参考文献样式等,输出达到出版的要求

  2. 多文档管理: 为编辑部所管理的不同期刊设置项目,为同一期刊的不同卷号、期号及不同论文设置文件夹。论文的文件夹中包括cls文件, 模板设置文件, TeX源文件,bib文献库,图片文件,等等

  3. 流程协同与权限管理:借助Overleaf的实时协作功能,构建排校系统所需的角色权限

  • 作者: 通过邀请作者拥有编辑自己稿件的权限
  • 编辑: 可访问多个稿件
  • 主编或编辑部主任: 定审
  1. 版本控制与历史追踪:Overleaf自动保存版本历史, 且提供作者或编辑处理过稿件的痕迹,通过”accept”或”reject”确定是否采用被修改的内容

演示示例: APS流程优化

演示示例: APS模板与使用说明

演示示例: APS 在线排校与发表流程

演示示例: APS 在线排校示意

IV. 文学化编程: Quarto

目录

  • I. 写作工具的选择:Markdown

  • II. 科技论文写作: \(\TeX\)

  • III. 排校系统的构建: Overleaf

  • IV. 文学化编程: Quarto

  • V. 书稿Quarto模板分享

4.1. Quarto 介绍

从 Rmarkdown 到 Quarto

  • Posit (前身为Rstudio) 全新打造: 下一代的RMarkdown, 于2021年1月开始开发,2022年12月发布第一版

  • Quarto 是一个基于 Pandoc 的现代开源科技出版系统

  • 功能更加强大和灵活: 适用于数据分析和机器学习等领域文学化编程

  • 支持代码块执行: R, Python,Julia,JavaScript Observable

  • 支持多格式输出: PDF、HTML、\(\LaTeX\)、Word 等

  • 支持自定义: CSS、JavaScript 和 \(\LaTeX\) 模板

平台

开源免费、高效、跨平台IDE,Visual 与 Source 两种编辑模式自由切换

图 3: Rstudio界面
图 4: VS Code界面

基于Quarto的文学化统计编程流程

图 5: Quarto 文学化统计编程流程

Quarto工作原理

图 6: Quarto工作原理

要素: 数学公式

通过\(\TeX\)/MathJax/KaTeX 实现

$$
\frac{\partial C}
     { \partial t} 
     + \frac{1}{2}\sigma^2 S^2
\frac{\partial^2 C}
     {\partial C^2}
     + r S 
       \frac{\partial C}
            {\partial S}
      \ = r C 
$$ {#eq-black-scholes}

\[\frac{\partial C} { \partial t} + \frac{1}{2}\sigma^{2} S^{2} \frac{\partial^{2} C} {\partial C^2} + r S \frac{\partial C} {\partial S} \ = r C \qquad(1)\]

要素: 执行R代码

par(mar = c(4, 4, 1, .1))
fit = lm(dist ~ 1 + speed, 
         data = cars)
plot(cars, pch = 19, 
     col = 'blue', 
     las = 1)
abline(fit, lwd = 2)
图 7: R图形: 回归分析

要素: 执行Python代码

# 需要加载R包 reticulate,并指定Python 
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.grid(True)
plt.show()
plt.close("all")
图 8: Python图形

要素: 插入本地图片

knitr::include_graphics("./loc-figs/Rlogo.png")
knitr::include_graphics("./loc-figs/python.png")
knitr::include_graphics("./loc-figs/julia-logo.png")

要素: 表格输出(kable)

require('knitr')
kable(iris, format = "html", caption = "Title of the table")
表 1: Title of the table
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
4.6 3.4 1.4 0.3 setosa
5.0 3.4 1.5 0.2 setosa
4.4 2.9 1.4 0.2 setosa
4.9 3.1 1.5 0.1 setosa
5.4 3.7 1.5 0.2 setosa
4.8 3.4 1.6 0.2 setosa
4.8 3.0 1.4 0.1 setosa
4.3 3.0 1.1 0.1 setosa
5.8 4.0 1.2 0.2 setosa
5.7 4.4 1.5 0.4 setosa
5.4 3.9 1.3 0.4 setosa
5.1 3.5 1.4 0.3 setosa
5.7 3.8 1.7 0.3 setosa
5.1 3.8 1.5 0.3 setosa
5.4 3.4 1.7 0.2 setosa
5.1 3.7 1.5 0.4 setosa
4.6 3.6 1.0 0.2 setosa
5.1 3.3 1.7 0.5 setosa
4.8 3.4 1.9 0.2 setosa
5.0 3.0 1.6 0.2 setosa
5.0 3.4 1.6 0.4 setosa
5.2 3.5 1.5 0.2 setosa
5.2 3.4 1.4 0.2 setosa
4.7 3.2 1.6 0.2 setosa
4.8 3.1 1.6 0.2 setosa
5.4 3.4 1.5 0.4 setosa
5.2 4.1 1.5 0.1 setosa
5.5 4.2 1.4 0.2 setosa
4.9 3.1 1.5 0.2 setosa
5.0 3.2 1.2 0.2 setosa
5.5 3.5 1.3 0.2 setosa
4.9 3.6 1.4 0.1 setosa
4.4 3.0 1.3 0.2 setosa
5.1 3.4 1.5 0.2 setosa
5.0 3.5 1.3 0.3 setosa
4.5 2.3 1.3 0.3 setosa
4.4 3.2 1.3 0.2 setosa
5.0 3.5 1.6 0.6 setosa
5.1 3.8 1.9 0.4 setosa
4.8 3.0 1.4 0.3 setosa
5.1 3.8 1.6 0.2 setosa
4.6 3.2 1.4 0.2 setosa
5.3 3.7 1.5 0.2 setosa
5.0 3.3 1.4 0.2 setosa
7.0 3.2 4.7 1.4 versicolor
6.4 3.2 4.5 1.5 versicolor
6.9 3.1 4.9 1.5 versicolor
5.5 2.3 4.0 1.3 versicolor
6.5 2.8 4.6 1.5 versicolor
5.7 2.8 4.5 1.3 versicolor
6.3 3.3 4.7 1.6 versicolor
4.9 2.4 3.3 1.0 versicolor
6.6 2.9 4.6 1.3 versicolor
5.2 2.7 3.9 1.4 versicolor
5.0 2.0 3.5 1.0 versicolor
5.9 3.0 4.2 1.5 versicolor
6.0 2.2 4.0 1.0 versicolor
6.1 2.9 4.7 1.4 versicolor
5.6 2.9 3.6 1.3 versicolor
6.7 3.1 4.4 1.4 versicolor
5.6 3.0 4.5 1.5 versicolor
5.8 2.7 4.1 1.0 versicolor
6.2 2.2 4.5 1.5 versicolor
5.6 2.5 3.9 1.1 versicolor
5.9 3.2 4.8 1.8 versicolor
6.1 2.8 4.0 1.3 versicolor
6.3 2.5 4.9 1.5 versicolor
6.1 2.8 4.7 1.2 versicolor
6.4 2.9 4.3 1.3 versicolor
6.6 3.0 4.4 1.4 versicolor
6.8 2.8 4.8 1.4 versicolor
6.7 3.0 5.0 1.7 versicolor
6.0 2.9 4.5 1.5 versicolor
5.7 2.6 3.5 1.0 versicolor
5.5 2.4 3.8 1.1 versicolor
5.5 2.4 3.7 1.0 versicolor
5.8 2.7 3.9 1.2 versicolor
6.0 2.7 5.1 1.6 versicolor
5.4 3.0 4.5 1.5 versicolor
6.0 3.4 4.5 1.6 versicolor
6.7 3.1 4.7 1.5 versicolor
6.3 2.3 4.4 1.3 versicolor
5.6 3.0 4.1 1.3 versicolor
5.5 2.5 4.0 1.3 versicolor
5.5 2.6 4.4 1.2 versicolor
6.1 3.0 4.6 1.4 versicolor
5.8 2.6 4.0 1.2 versicolor
5.0 2.3 3.3 1.0 versicolor
5.6 2.7 4.2 1.3 versicolor
5.7 3.0 4.2 1.2 versicolor
5.7 2.9 4.2 1.3 versicolor
6.2 2.9 4.3 1.3 versicolor
5.1 2.5 3.0 1.1 versicolor
5.7 2.8 4.1 1.3 versicolor
6.3 3.3 6.0 2.5 virginica
5.8 2.7 5.1 1.9 virginica
7.1 3.0 5.9 2.1 virginica
6.3 2.9 5.6 1.8 virginica
6.5 3.0 5.8 2.2 virginica
7.6 3.0 6.6 2.1 virginica
4.9 2.5 4.5 1.7 virginica
7.3 2.9 6.3 1.8 virginica
6.7 2.5 5.8 1.8 virginica
7.2 3.6 6.1 2.5 virginica
6.5 3.2 5.1 2.0 virginica
6.4 2.7 5.3 1.9 virginica
6.8 3.0 5.5 2.1 virginica
5.7 2.5 5.0 2.0 virginica
5.8 2.8 5.1 2.4 virginica
6.4 3.2 5.3 2.3 virginica
6.5 3.0 5.5 1.8 virginica
7.7 3.8 6.7 2.2 virginica
7.7 2.6 6.9 2.3 virginica
6.0 2.2 5.0 1.5 virginica
6.9 3.2 5.7 2.3 virginica
5.6 2.8 4.9 2.0 virginica
7.7 2.8 6.7 2.0 virginica
6.3 2.7 4.9 1.8 virginica
6.7 3.3 5.7 2.1 virginica
7.2 3.2 6.0 1.8 virginica
6.2 2.8 4.8 1.8 virginica
6.1 3.0 4.9 1.8 virginica
6.4 2.8 5.6 2.1 virginica
7.2 3.0 5.8 1.6 virginica
7.4 2.8 6.1 1.9 virginica
7.9 3.8 6.4 2.0 virginica
6.4 2.8 5.6 2.2 virginica
6.3 2.8 5.1 1.5 virginica
6.1 2.6 5.6 1.4 virginica
7.7 3.0 6.1 2.3 virginica
6.3 3.4 5.6 2.4 virginica
6.4 3.1 5.5 1.8 virginica
6.0 3.0 4.8 1.8 virginica
6.9 3.1 5.4 2.1 virginica
6.7 3.1 5.6 2.4 virginica
6.9 3.1 5.1 2.3 virginica
5.8 2.7 5.1 1.9 virginica
6.8 3.2 5.9 2.3 virginica
6.7 3.3 5.7 2.5 virginica
6.7 3.0 5.2 2.3 virginica
6.3 2.5 5.0 1.9 virginica
6.5 3.0 5.2 2.0 virginica
6.2 3.4 5.4 2.3 virginica
5.9 3.0 5.1 1.8 virginica

4.2. \(\TeX\) 模板向自定义Quarto模板的转换

Quarto的工作原理

  • Quarto是基于Pandoc构建的

  • Quarto工作原理:

    • Quarto 使用 Pandoc 模板将 markdown 文件转换为渲染输出.

    • Pandoc 模板由特定格式的内容和变量(例如$body$)组合而成,这些变量在渲染时会被文档中的实际值替换.

  • 做法:

    • 替换LaTeX(或HTML)完整模板,此虽可完全掌控渲染输出,但成本很高且易出错;

    • 选择性替换LaTeX(或HTML)模板中的局部组件(以.tex为后缀);这是通过LaTeX Partials(局部模板)来实现的.

  • 这些局部模板是构建称为Quarto扩展(个性化模型)的主要组件.

Quarto扩展(extensions)

  • Quarto扩展 是一种强大且灵活的Quarto增强方式,为他人提供可重复使用的自定义格式模板, 有以下几类扩展:

    1. 格式模板(format templates), 用于预定义文档的输出格式(html,pdf,word,epub,revealjs等) 及主题等。示例:
    format:
      pdf:
        template: acm-template.tex
      html:
        theme: cosmo, darkly
    1. 局部模板(partial templates), 用于定制文档的局部结构,如页眉、页脚、标题页等。 示例:
format:
  pdf:
    include-fefore-body: path/before-body.tex
  html:
    include-fefore-body: path/title-block.html
  1. 短代码扩展(shortcodes)

  2. 过滤器扩展(filters), 用于修改文档内容或行为。

  3. 自定义函数(Custom Functions)

  4. 语法高亮扩展(Syntax Highlighting)

局部模板(partials)

  • 定义: 局部模板(partials)为以特定顺序连接的 \(\LaTeX\) 小片段(.tex文件), 这些文件必须采用Pandoc默认模板中预定义的特定名称. 详见Github: Pandoc LaTeX Partials

  • 作用: 替换或扩展Pandoc默认LaTeX模板的特定部分,而无需重写整个模板,达到局部定制和精细地控制PDF/LaTeX输出的目的.

  • 典型应用场景: 在正文开始前添加摘要、致谢;自定义标题页、页眉页脚;调整目录、图表列表的格式或位置.

  • 配置方式: 在配置文件_quarto.yml中,通过template-partials 选项来指定。例如:

format:
  pdf:
    template-partials:
      - before-body.tex
      - title.tex
  • 优势: 使用局部模板通常比维护一个完整的自定义LaTeX模板(通过 template 指定)更简单, 维护成本低.

常用的局部模板及与\(\LaTeX\)中内容的对应关系

  • Quarto文档的 pdf 输出依赖于一系列默认的局部片段构建的局部模板,

  • 提供\(\TeX\)模板所需要的元信息,包括论文题目、作者、单位、关键词、导师、专业、摘要、关键词等。这些文件置于_extensions\extension-name\partials目录下。

  • 常用的局部模板有:

    • doc-class.tex\documentclass[]{}内容)
    • before-title.tex (与in-header.tex类同)
    • in-header.tex (宏包与基本的设置)
    • title.tex (\author, \affil, \keywords 等设置)
    • before-body.tex\frontmatter … 标题页,摘要 \mainmatter
    • after-body.tex (\backmatter …参考文献 )
    • before-bib.tex (正文之后参考文献之前的内容,如期刊中的funds/基金, conflicts of interest/利益冲突, acknowledgments/致谢)

Quarto YAML 配置

---
title: "My Document"
format:
  pdf:
    # 文档类配置(等效于 doc-class.tex)
    documentclass: article
    classoption: [12pt, a4paper]

    template-partials:
      - in-header.tex
      - before-title.tex
      - title.tex
      - before-body.tex
      - after-body.tex
---
---
title: "My Document"
format:
  pdf:
    # 文档类配置(等效于 doc-class.tex)
    documentclass: article
    classoption: [12pt, a4paper]

    # 各插入文件配置
    include-in-header: 
      file: preamble.tex          # 导言区宏包和命令
    include-before-title: 
      file: cover.tex             # 封面(标题前)
    include-before-body: 
      file: abstract-toc.tex      # 摘要和目录
    include-after-body: 
      file: appendix.tex          # 附录
    # before-bib.tex 需手动合并到 after-body.tex 或通过模板处理
---
% doc-class.tex 的内容会通过 Quarto YAML 的 documentclass 生成
\documentclass[12pt]{article} 

% in-header.tex 插入在此(导言区)
\usepackage{geometry}
\geometry{a4paper, margin=1in}
% ...其他导言区设置

\begin{document}

% before-title.tex 插入在此(标题前)
\begin{center}
  \includegraphics{cover.jpg} % 自定义封面
\end{center}

% title.tex 插入在此(若自定义)
\title{Custom Title}
\author{Author}
\maketitle

% before-body.tex 插入在此(标题后)
\tableofcontents
\begin{abstract}
  Summary here.
\end{abstract}

% Quarto 生成的正文内容
\section{Introduction}
...

% before-bib.tex 插入在此(若手动添加)
\section*{References}
% 参考文献列表(如 \bibliography)

% after-body.tex 插入在此(文档末尾)
\appendix
\section{Appendix}
...

\end{document}

4.3. 期刊Quarto模板

Quarto期刊论文

  • 期刊论文创建需要标准化个性化的协调与统一, 方便期刊的集约化管理.

  • Quarto支持创建自定义格式(format),扩展基础格式(如pdf、html和docx), 从而灵活地适应各类专业期刊论文创建的需要.

  • Quarto支持“单一来源发布”,即相同的Quarto文档源能够生成HTML和\(\LaTeX\)输出,还能够创建适合多个期刊所需的\(\LaTeX\)输出。实现此功能的关键功能包括:

    • \(\TeX\)模板适配: 配合Pandoc,能够灵活地为期刊提供本地\(\LaTeX\)模板;

    • 自定义: 通过CSS实现针对HTML输出的定制; 通过\(\LaTeX\)实现针对pdf输出的定制;

    • 作者与单位: 根据各种期刊所需的样式(style)自动格式化作者和隶属关系的标准化模式;

    • 文献引用: 借助引文样式语言(CSL),根据各种期刊所需的样式自动格式化引文和参考文献.

更多参见Quarto提供的Journal Articles及多个期刊格式。

推荐阅读文章

  1. Article Templates 阐述如何创建与Pandoc完美兼容的自定义期刊模板,它不仅融合了期刊专用LaTeX语法与Pandoc所需的标准指令,而且可以生成符合出版要求的高保真输出成果。文章还重点介绍了构建Quarto自定义模板所需要的主要局部模板:

    • LaTeX/Beamer/Typst/HTML/Revealjs partials
  2. Demo aft format to use as template 介绍John Doe所开发的Quarto论文模板article-format-template(aft) 的设置与使用. 此扩展可在Github下载.

  3. Creating Quarto Journal Article Templates 介绍了作者 Christopher T. Kenny 基于\(\LaTeX\)模板开发Quarto期刊模板pnas的历程.

  4. Quarto template for writing academic papers, by 王海林

  5. Quarto Template for Chinese Academic Writing, by Tom Bener中文介绍(从 Pandoc 到 Quarto:纯文本学术写作的实践与优化)

  6. 探索Hikmah Quarto模板:学术出版的革命性工具

期刊quarto格式(format template)创建步骤

  • 调整 \(\LaTeX\) 模板:将期刊通常提供的 \(\LaTeX\) 模板进行适配,使其适用于 Quarto

  • 选择引用处理方式:为该格式选取合适的引用处理流程和样式

  • 创建模板文件:编写 template.qmd 文件来演示该格式的使用方法

  • 可选优化:确保同时为 HTML 和 \(\LaTeX\) 文章提供良好支持

Journal Articles或其Github 提供了Quarto团队开发的一些期刊格式模板.

Quarto 团队开发或其他作者分享的期刊模板

演示示例: tstf/STARF 模板

├── _extensions
    └── tandf
        ├── _extension.yml
        ├── interact.cls
        └── patials
            ├── _affiliations.tex
            ├── _authors.tex
            ├── before-body.tex
            └── title.tex
        └── shortcodes.lua
    ├── _publish.yml
    ├── _quarto.yml
    ├── bibliography.bib
    ├── interact.cls
    ├── README.md
    ├── sunflower.png
    └──  tstf-template.qmd
\documentclass[]{interact}

\usepackage{epstopdf}% To incorporate .eps illustrations using PDFLaTeX, etc.
\usepackage[caption=false]{subfig}% Support for small, `sub' figures and tables

% First with apacite style
\usepackage[natbibapa,nodoi]{apacite}% Citation support using apacite.sty. Commands using natbib.sty MUST be deactivated first!
\setlength\bibhang{12pt}% To set the indentation in the list of references using apacite.sty. Commands using natbib.sty MUST be deactivated first!
\renewcommand\bibliographytypesize{\fontsize{10}{12}\selectfont}% To set the list of references in 10 point font using apacite.sty. Commands using natbib.sty MUST be deactivated first!

%% Second with apalike style (natbib package)
%\usepackage[longnamesfirst,sort]{natbib}% Citation support using natbib.sty
%\bibpunct[, ]{(}{)}{;}{a}{,}{,}% Citation support using natbib.sty
%\renewcommand\bibfont{\fontsize{10}{12}\selectfont}% To set the list of references in 10 point font using natbib.sty

\theoremstyle{plain}% Theorem-like structures provided by amsthm.sty
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{notation}{Notation}

\begin{document}

\articletype{STARF ARTICLE TEMPLATE with apacite style}% Specify the article type or omit as appropriate

\title{TSTF \LaTeX\ template} %(\textsf{Interact} layout + APA reference style)

\author{
\name{Michael J
    Mahoney\textsuperscript{a}, Another
    One\textsuperscript{a}, Someone Else$\textsuperscript{b}$}
\affil{\textsuperscript{a}Graduate Program in Environmental Science, State
    University of New York College of Environmental Science and
    Forestry, Syracuse, NY, USA;\\ \textsuperscript{b}Department of
    Sustainable Resources Management, State University of New York College
    of Environmental Science and Forestry, Syracuse, NY, USA}
}

\thanks{CONTACT: Michael J
    Mahoney. Email: fake.email@fakeyfake.com}

\maketitle

\begin{abstract}
This template is for authors who are preparing a manuscript for a Taylor \& Francis journal using the \LaTeX\ document preparation system and the \texttt{interact} class file, which is available via selected journals' home pages on the Taylor \& Francis website.
\end{abstract}

\begin{keywords}
Sections; lists; figures; tables; mathematics; fonts; references; appendices
\end{keywords}


\section{Introduction}
...

...
---
title: "Demo Taylor and Francis template"
format:
  tandf-pdf:
    keep-tex: true  
  tandf-html: default
author:
  - name: Michael J Mahoney
    affiliations:
      - ref: GPES
    orcid: 0000-0003-2402-304X
    email: fake.email@fakeyfake.com
    url: https://mm218.dev
  - name: Another One
    affiliations:
      - ref: GPES
  - name: Someone Else
    email: test@email.com
    affiliations:
      - ref: SRM
affiliations:
  - id: GPES
    name: State University of New York College of Environmental Science and Forestry
    department: Graduate Program in Environmental Science
    address: 1 Forestry Drive
    city: Syracuse, NY
    country: USA
    postal-code: 13210
  - id: SRM
    name: State University of New York College of Environmental Science and Forestry
    department: Department of Sustainable Resources Management
    address: 1 Forestry Drive
    city: Syracuse, NY
    country: USA
    postal-code: 13210
abstract: |
  This document is only a demo explaining how to use the template.
keywords: 
  - TSTF template
  - demo
bibliography: bibliography.bib  
---

# Introduction {#sec-intro}

This is an example of how to use this template to render journal articles. This template is inspired by the Taylor and Francis rticles template for rmarkdown, repurposed for the Quarto publishing system.

This quarto extension format supports PDF and HTML outputs. This template is primarily focused on generating acceptable {{< latex >}} outputs from Quarto, but renders an acceptable HTML output using the standard Quarto options.

# Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.



# Markdown Basics

This section of the template is adapted from [Quarto's documentation on Markdown basics](https://quarto.org/docs/authoring/markdown-basics.html).

## Text Formatting

+-----------------------------------+-------------------------------+
| Markdown Syntax                   | Output                        |
+===================================+===============================+
|     *italics* and **bold**        | *italics* and **bold**        |
+-----------------------------------+-------------------------------+
|     superscript^2^ / subscript~2~ | superscript^2^ / subscript~2~ |
+-----------------------------------+-------------------------------+
|     ~~strikethrough~~             | ~~strikethrough~~             |
+-----------------------------------+-------------------------------+
|     `verbatim code`               | `verbatim code`               |
+-----------------------------------+-------------------------------+

## Headings {#headings}

+---------------------+-----------------------------------+
| Markdown Syntax     | Output                            |
+=====================+===================================+
|     # Header 1      | # Header 1 {.heading-output}      |
+---------------------+-----------------------------------+
|     ## Header 2     | ## Header 2 {.heading-output}     |
+---------------------+-----------------------------------+
|     ### Header 3    | ### Header 3 {.heading-output}    |
+---------------------+-----------------------------------+

## Equations

Use `$` delimiters for inline math and `$$` delimiters for display math. For example:

+-------------------------------+-------------------------+
| Markdown Syntax               | Output                  |
+===============================+=========================+
|     inline math: $E = mc^{2}$ | inline math: $E=mc^{2}$ |
+-------------------------------+-------------------------+
|     display math:             | display math:\          |
|                               | $$E = mc^{2}$$          |
|     $$E = mc^{2}$$            |                         |
+-------------------------------+-------------------------+

If assigned an ID, display math equations will be automatically numbered:

$$
\frac{\partial \mathrm C}{ \partial \mathrm t } + \frac{1}{2}\sigma^{2} \mathrm S^{2}
\frac{\partial^{2} \mathrm C}{\partial \mathrm C^2}
  + \mathrm r \mathrm S \frac{\partial \mathrm C}{\partial \mathrm S}\ =
  \mathrm r \mathrm C 
$$ {#eq-black-scholes}

## Other Blocks

+-----------------------------+--------------------------+
| Markdown Syntax             | Output                   |
+=============================+==========================+
|     > Blockquote            | > Blockquote             |
+-----------------------------+--------------------------+
|     | Line Block            | | Line Block             |
|     |   Spaces and newlines | |    Spaces and newlines |
|     |   are preserved       | |    are preserved       |
+-----------------------------+--------------------------+

## Cross-references {#sec-crf}

![A sunflower](sunflower.png){#fig-sunflower}

+---------------------------------------+---------------------------------+
| Markdown Format                       | Output                          |
+=======================================+=================================+
|     @fig-sunflower is pretty.         | @fig-sunflower is pretty.       |
+---------------------------------------+---------------------------------+
|     @tbl-glm was created from code.   | @tbl-glm was created from code. |
+---------------------------------------+---------------------------------+
|     @sec-crf is this section.         | @sec-crf is this section.       |
+---------------------------------------+---------------------------------+
|     @eq-black-scholes is above.       | @eq-black-scholes is above.     |
+---------------------------------------+---------------------------------+

See the [Quarto documentation on cross-references for more](https://quarto.org/docs/authoring/cross-references.html).


# Citations

This section of the template is adapted from the [Quarto citation documentation](https://quarto.org/docs/authoring/footnotes-and-citations.html).

Quarto supports bibliography files in a wide variety of formats including BibTeX and CSL. Add a bibliography to your document using the `bibliography` YAML metadata field. For example:

``` yaml
---
title: "My Document"
bibliography: references.bib
---
```

See the [Pandoc Citations](https://pandoc.org/MANUAL.html#citations) documentation for additional information on bibliography formats.


## Citation Syntax {#sec-citations}

Quarto uses the standard Pandoc markdown representation for citations. Here are some examples:


+-------------------------------------------+---------------------------------------------------------------------+
| Markdown Format                           | Output                                                              |
+===========================================+=====================================================================+
|     Blah Blah [see @knuth1984, pp. 33-35; | Blah Blah [see @knuth1984, pp. 33-35; also @wickham2015, chap. 1]   |
|     also @wickham2015, chap. 1]           |                                                                     |
+-------------------------------------------+---------------------------------------------------------------------+
|     Blah Blah [@knuth1984, pp. 33-35,     | Blah Blah [@knuth1984, pp. 33-35, 38-39 and passim]                 |
|     38-39 and passim]                     |                                                                     |
+-------------------------------------------+---------------------------------------------------------------------+
|     Blah Blah [@wickham2015; @knuth1984]. | Blah Blah [@wickham2015; @knuth1984].                               |
+-------------------------------------------+---------------------------------------------------------------------+
|     Wickham says blah [-@wickham2015]     | Wickham says blah [-@wickham2015]                                   |
+-------------------------------------------+---------------------------------------------------------------------+

You can also write in-text citations, as follows:

+-----------------------------------+-------------------------------+
| Markdown Format                   | Output                        |
+===================================+===============================+
|     @knuth1984 says blah.         | @knuth1984 says blah.         |
+-----------------------------------+-------------------------------+
|     @knuth1984 [p. 33] says blah. | @knuth1984 [p. 33] says blah. |
+-----------------------------------+-------------------------------+

See the [Pandoc Citations](https://pandoc.org/MANUAL.html#citations) documentation for additional information on citation syntax.

To provide a custom citation stylesheet, provide a path to a CSL file using the `csl` metadata field in your document, for example:

``` yaml
---
title: "My Document"
bibliography: references.bib
csl: nature.csl
---
```



# References {.unnumbered}

::: {#refs}
:::

总结: AI时代写作与出版的路径

  1. 基于\(\TeX\)构建

    • 模板定制: 减少使用的成本

    • Overleaf: 提升协同校排能力

    • markdown: 通过markdown宏包实现在\(\TeX\)中使用markdown写作

  2. 基于Quarto构建

    • markdown: 专注写作

    • \(\TeX\): 专注数学排版

    • R/Python/…:专注编程

    • Pandoc:

      • 实现融合(文学化编程)
      • 多板式的输出(html, pdf, doc)
    • 模板定制:

      • 期刊模板
      • 书稿模板
      • 幻灯片模板

V. 书稿Quarto模板分享

目录

  • I. 写作工具的选择:Markdown

  • II. 科技论文写作: \(\TeX\)

  • III. 排校系统的构建: Overleaf

  • IV. 文学化编程: Quarto

  • V. 书稿Quarto模板分享

Quarto books

  • Quarto Books,新一代bookdown, 将多个文档以章节形式组合起来,并以不同的形式呈现出来

    • HTML
    • PDF
    • MS Word
    • EPUB
  • HTML和PDF是两种主要的形式, 支持章节、公式、图形、表格、参考文献等的交叉引用.

演示示例



Thank you!

Stanley Tang (汤银才)
github: tangyc8866
Homepage: Homepage
Email: yctang@stat.ecnu.edu.cn
WeChat: tangyincai