我正在使用 pandoc 将我的 .tex 文件转换为 PDF,但我的定义未被使用。示例:
\documentclass[12pt,letterpaper]{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[doublespacing]{setspace}
\usepackage{booktabs}
\begin{document}
\section{Test}
We make a few claims, and many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many more.
\begin{table}[htbp]
\begin{center}
\begin{tabular}
{@{}lr@{}}
\toprule
key & value \\
\midrule
a & 1 \\
b & 2 \\
\bottomrule
\end{tabular}
\caption{This table better look good.}
\end{center}
\end{table}
\end{document}
使用 进行编译pandoc -o out.pdf test.tex
,结果如下:
因此,几何形状和双倍行距会被忽略,并且书页标签不起作用。
现在,我可以手动将几何图形和间距传递给 pandoc 调用,但为什么不使用文件中的值?另外,我该怎么做才能让 booktabs 正常工作?
答案1
你不能使用 pandoc 将 tex 转换为 pdf
只需调用pfdlatex test.tex
即可编译您的 .tex 文件。为了使 booktabs 正常工作,您必须通过添加到\usepackage{booktabs}
文件的前言来加载该包:
\documentclass[12pt]{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[doublespacing]{setspace}
\usepackage{booktabs}
\begin{document}
\section{Test}
We make a few claims, and many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many more.
\begin{table}[htbp]
\begin{center}
\begin{tabular}
{@{}lr@{}}
\toprule
key & value \\
\midrule
a & 1 \\
b & 2 \\
\bottomrule
\end{tabular}
\caption{This table better look good.}
\end{center}
\end{table}
\end{document}
或者,如果您想使用 pandoc,请以 markdown 格式编写文本:
---
fontsize: 12pt
papersize: a4
linestretch: 2
geometry:
- 'margin=1in'
---
Test
====
We make a few claims, and many, many, many, many, many, many, many,
many, many, many, many, many, many, many, many, many, many, many, many,
many, many more.
key value
----- -------
a 1
b 2
: This table better look good.
这一切都有很好的记录pandoc.org