在转换为pdf时,pandoc不会自动换行代码块 [英] pandoc doesn't text-wrap code blocks when converting to pdf

查看:680
本文介绍了在转换为pdf时,pandoc不会自动换行代码块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有xelatex引擎的pandoc将markdown转换为pdf.我正在这样运行pandoc:

I'm using pandoc with xelatex engine to convert markdown to pdf. I'm running pandoc like this:

pandoc -s 'backbone-fundamentals'.md -o 'backbone-fundamentals'.pdf \
    --title-prefix 'Developing Backbone.js Applications' \
    --normalize \
    --smart \
    --toc \
    --latex-engine=`which xelatex`

如果代码行长于pdf文档宽度,则会被截断.反正Pandoc文本会包装长代码行吗?

If a code line is longer than the pdf document width it just gets cutoff. Is there anyway to have pandoc text wrap long code lines?

推荐答案

不包装文本是代码块的一部分.据我所知,包装代码的唯一方法是手动.对于大多数语言而言,不超过特定行长始终被认为是一种好的样式.

Not having the text wrapped is (part of) the point of code blocks. As far as I know, the only way to wrap the code is manually. For most languages, not exceeding a certain line length is considered good style anyway.

如果行受长度限制,但对于LaTeX生成的pdf来说仍然太长,请考虑减少代码块的字体大小.为此,您需要更改pandoc使用的LaTeX模板.看一下答案,以了解如何在Beamer演示文稿中为所有普通字体设置字体大小?"应该会让您入门.

If your lines are length-limited but still too long for your LaTeX-generated pdf, consider reducing the font size for code blocks. For this you need to change the LaTeX template used by pandoc. A look at this answer to "How to set font size for all verbatims in Beamer presentation?" should get you started.

这篇关于在转换为pdf时,pandoc不会自动换行代码块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆