[英]Tables or images too wide in Pandoc output as DOCX or PDF/LaTeX
I am writing a quick and dirty report using pandoc and markdown. 我正在使用pandoc和markdown写一个快速而肮脏的报告。
I need to generate a PDF or a DOCX with minimum hassle, I don't care much about which (best would be both, of course). 我需要以最小的麻烦生成PDF或DOCX,我不在乎哪个(当然最好是两者)。 Also, I am somewhat constrained regarding the figures and tables -- they have been generated a priori with another program and I would rather be able to insert them as they are then to convert them to suit pandoc's needs.
此外,我对数字和表格有一定的限制 - 它们已经与另一个程序先验地生成,我宁愿能够插入它们,因为它们将它们转换为适合pandoc的需要。
However, the main constraint is that I don't want to edit the resulting document manually, be that LaTeX or DOCX. 但是,主要的限制是我不想手动编辑生成的文档,无论是LaTeX还是DOCX。 I want to do all editing in markdown.
我想在降价时进行所有编辑。
Here is the problem: 这是问题所在:
Thus, none of the documents generated are usable for my purposes. 因此,生成的文档都不能用于我的目的。
All I wanted to do is to slap together some results and generate a file that I can send to another scientist. 我想做的就是将一些结果拼凑在一起并生成一个我可以发送给另一位科学家的文件。
Question: what is the best solution to generate a quick and dirty report in pandoc with minimum effort and at least all results visible? 问题:在pandoc中以最小的努力生成快速而脏的报告的最佳解决方案是什么,并且至少可以看到所有结果?
Update: Upgrading pandoc to 1.4 or later solves the issue -- the figures have now correct sizes in docx documents. 更新:将pandoc升级到1.4或更高版本可以解决问题 - 这些数字现在在docx文档中具有正确的大小。
Currently you cannot control that feature directly from Markdown. 目前,您无法直接从Markdown控制该功能。 For LaTeX/PDF output, this is automatically handled by LaTeX/pdflatex itself.
对于LaTeX / PDF输出,这由LaTeX / pdflatex本身自动处理。
In recent months there have been some discussions going on in the Pandoc developer + user community about how to best implement it and create an easy-to-use syntax, for example 最近几个月,Pandoc开发人员和用户社区一直在讨论如何最好地实现它并创建一个易于使用的语法,例如
![Image Caption](./path/to/image.jpg "Image Comment"){width="60%", height="150px"}
( Warning: Example only, made up on the spot + extracted from thin air by myself -- can't remember the latest state of the discussion...) This is designed to then transfer to all the supported output formats which can contain images, not just to LaTeX/PDF. ( 警告:仅限示例,由现场制作+由我自己从空气中提取 - 无法记住讨论的最新状态...)这是为了转移到所有支持的输出格式,可以包含图像,而不仅仅是LaTeX / PDF。
So something along these lines is planned to be a major new feature for the next major release of Pandoc, and will start to be working better in ODT/DOCX output as well. 因此,计划成为Pandoc下一个主要版本的主要新功能,并且将开始在ODT / DOCX输出中更好地工作。
How exactly do you specify your tables in Markdown syntax? 您如何在Markdown语法中指定表格?
Are you aware that Pandoc supports several variations like gid_tables
, pipe_tables
, simple_tables
and multiline_tables
? 您是否知道Pandoc支持多种变体,如
gid_tables
, pipe_tables
, simple_tables
和multiline_tables
?
You should look into using pandoc --from=markdown+multiline_tables ...
as your command and write the critical tables as multiline_tables
in your Markdown. 您应该考虑使用
pandoc --from=markdown+multiline_tables ...
作为您的命令,并将关键表格作为Markdown中的multiline_tables
写入。
Read all about the details via man pandoc_markdown
... 通过
man pandoc_markdown
阅读所有关于细节的信息......
Multiline tables give you a limited control over the width of individual columns in the output, just by widening or narrowing the column widths in the markdown source itself. 多行表使您可以有限地控制输出中各列的宽度,只需通过加宽或缩小降价源本身的列宽即可。
Pandoc supports the insertion of raw_tex
lines and environments into the Markdown source file. Pandoc支持将
raw_tex
行和环境插入Markdown源文件。 When it encounters such lines, it transmits them un-changed into its LaTeX output. 当遇到这样的行时,它会将它们未更改地传输到其LaTeX输出中。 (But it will be ignored for all other outputs.)
(但是对于所有其他输出,它将被忽略。)
So you can insert lines like 所以你可以插入像这样的行
\newpage{}
into the Markdown to enforce a page break. 进入Markdown以强制执行分页符。 This already gives you some limited control over keeping the order of mis-behaving figures or tables.
这已经为您提供了一些有限的控制,可以保持错误的数字或表格的顺序。 (After all, you said you look for a "quick and dirty" method, not a sophisticated typeset document...)
(毕竟,你说你寻找一个“快速而肮脏”的方法,而不是复杂的排版文档...)
Of course, if you know LaTeX more and better, you can also use stuff like /FloatBarrier
inside your Markdown. 当然,如果你更了解LaTeX,你也可以在你的Markdown中使用像
/FloatBarrier
这样的东西。
Going down that road (mixing LaTeX code into Markdown) gives you a few disadvantages: 走这条路(将LaTeX代码混合到Markdown)会给你带来一些缺点:
But the advantage still are: 但优势仍然是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.