pandoc输出中文pdf cmd命令记录

2022年12月7日更新

不知道为什么命令不行了,重新修改了一下


pandoc --pdf-engine=xelatex -V CJKmainfont=‘黑体’ -V mainfont=‘Times New Roman’ -V geometry:margin=1in --highlight-style tango test.md -o test.pdf

pandoc --pdf-engine=xelatex -V CJKmainfont="黑体" -V geometry:margin=1in --highlight-style tango test.md -o test1.pdf

上面设置了

  • pdf的编译器为xelatex
  • 中文字体为黑体
  • 英文字体为Times New Roman
  • 页边距:1inch
  • 代码块高亮格式:tango

下次再调用就一键复制就好了

另外可以额外编写一个tex的文件,在里面修改latex需要的参数,比如用@jdhao的方法,边距等参数都可以设置在tex里面,这样外面命令行窗口就不用输入那么多命令了。

\usepackage{fancyvrb,newverbs} 
\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}

% change background color for inline code in 
% markdown files. The following code does not work well for 
% long text as the text will exceed the page boundary 

\definecolor{bgcolor}{HTML}{E0E0E0} \let\oldtexttt\texttt

\renewcommand{\texttt}[1]{   
\colorbox{bgcolor}{\oldtexttt{#1}} 
}

%% color and other settings for hyperref package \hypersetup{
    bookmarksopen=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=RoyalBlue, }

保存为head.tex,命令里再加上一句-H head.tex就可以了。

pandoc --pdf-engine=xelatex -V CJKmainfont=‘黑体’ -V mainfont=‘Times New Roman’ -V geometry:margin=1in --highlight-style -H head.tex tango test.md -o test.pdf

pandoc --pdf-engine=xelatex -H head.tex test.md -o test.pdf

不过不知道为什么我的hypersetup会报错,可能我的latex没有这个包?不过我不需要超链接颜色的修改,最后的这个\hypersetup这一段可以删掉。

另外@jdhao还进行了Sublime Text build system,简化编译生成 PDF 以及预览的整个过程。我还没有试过,不过觉得简化流程的思路真好,以后可以试试。先记着吧。

可以在他的Github上进行下载:
链接参见文末的[2]。

平常还可以看看官方文档,上面可能也有帮助。

相关参考
[1]纯文本做笔记 — 使用 Pandoc 把 Markdown 转为 PDF 文件
[2]jdhao/Markdown2PDF.sublime-build
[3]pandoc官方文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值