简体   繁体   English

输出格式化文本(包括源代码)作为LaTeX,PDF和HTML

[英]Output formatted text (including source code) as LaTeX, PDF and HTML

I am editing a lot of documents in latex that consist of code listings and are currently output to pdf. 我正在使用代码清单编辑乳胶中的许多文档,目前输出为pdf。

Since I am working in teams on those documents, I often need to manually integrate changes done by group members to the latex source. 由于我在这些文档的团队中工作,我经常需要手动将组成员所做的更改集成到latex源中。

Most of the group members do not know latex, so I would like to have a means to enable them to do the document formatting in a style maybe similar to markdown. 大多数小组成员都不知道乳胶,所以我想有办法让他们以类似于降价的方式进行文件格式化。

Since the latex documents consist of figures, have references and use the lslisting package, I am wondering if it would be possible to map these specific areas to a simple markdown style syntax. 由于乳胶文档由数字组成,有引用并使用lslisting包,我想知道是否可以将这些特定区域映射到简单的markdown样式语法。

Workflow Example: 工作流程示例:

  • Edit file in Markdown (or similar) 在Markdown(或类似)中编辑文件
    • tag sections 标签部分
    • tag code areas 标记代码区域
    • tag figures 标签数字
    • tag references 标签引用
  • convert to latex 转换为乳胶
    • automatically convert tags 自动转换标签
  • output 产量
    • pdf PDF格式
    • html HTML

Would it somehow be possible to achieve such a workflow? 它能以某种方式实现这样的工作流程吗? Maybe there are already solutions to my specific workflow? 也许我的特定工作流程已有解决方案?

Here is an example for Docutils. 这是Docutils的一个例子。

Title
=====

Section
-------

.. _code:

Code area::

  #include <iostream>
  int main() {
    std::cout << "Hello World!" << std::endl;
  }

.. figure:: image.png

   Caption for figure

A reference to the code_


Another section
---------------

- Itemize
- lists

#. Enumerated
#. lists

+-----+-----+
|Table|Table|
+-----+-----+
|Table|Table|
+-----+-----+

Save that as example.rst . 保存为example.rst Then you can compile to HTML: 然后你可以编译成HTML:

rst2html example.rst example.html

or to LaTeX: 或者到LaTeX:

rst2latex example.rst example.tex

then compile the resulting LaTeX document: 然后编译生成的LaTeX文档:

pdflatex example.tex
pdflatex example.tex  # twice to get the reference right

A more comprehensive framework for generating documents from multiple sources is Sphinx , which is based on Docutils and focuses on technical documentation. 用于从多个来源生成文档的更全面的框架是Sphinx ,它基于Docutils并专注于技术文档。

You should look at pandoc (at least if I understand your question correctly). 你应该看看pandoc (至少如果我理解你的问题)。 It can convert between multiple formats (tex, pdf, word, reStructuredText) and also supports extended versions of markdown syntax to handle more complex issues (eg inserting header information in html). 它可以在多种格式(tex,pdf,word,reStructuredText)之间进行转换,并且还支持markdown语法的扩展版本,以处理更复杂的问题(例如,在html中插入标题信息)。

With it you can mix markdown and LaTeX, and then compile to html, tex and pdf. 有了它你可以混合markdown和LaTeX,然后编译为html,tex和pdf。 You can also include bibtex references from an external file. 您还可以包含外部文件中的bibtex引用。

Some examples (from markdown to latex and html): 一些例子(从markdown到latex和html):

pandoc -f markdown -t latex infile.txt -o outfile.tex
pandoc -f markdown -t html infile.txt -o outfile.html

To add your own LaTex template going from markdown to pdf, and a bibliography: 要添加自己的LaTex模板,从markdown到pdf,以及参考书目:

 pandoc input.text --template=FILE --bibliography refs.bib -o outfile.pdf

It is really a flexible and awesome program, and I'm using it much myself. 它真的是一个灵活而精彩的程序,而且我自己也在使用它。

你看过Docutils吗?

If you are an Emacs user, you may find org-mode 's markup to your liking. 如果您是Emacs用户,您可以根据自己的喜好找到org-mode的标记。 It has very nice support for tables, coordinates well with other Emacs modes like the spreadsheet, and has good export of images to HTML. 它对表格有很好的支持,可以很好地与电子表格等其他Emacs模式进行协调,并且可以很好地将图像导出为HTML。 Cf. 参看 the fine manual's HTML-export section . 精细手册的HTML导出部分

org-mode files are editable outside Emacs, for team members who do not use it, although the previewing and embedding of other Emacs modes can, naturally, only be done with Emacs. 对于不使用它的团队成员,可以在Emacs外部编辑org-mode文件,尽管其他Emacs模式的预览和嵌入当然只能通过Emacs完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM