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.

Since I am working in teams on those documents, I often need to manually integrate changes done by group members to the latex source.

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.

Workflow Example:

  • Edit file in Markdown (or similar)
  • tag sections
  • tag code areas
  • tag figures
  • tag references
  • convert to latex
  • automatically convert tags
  • output
  • pdf
  • html
  • Would it somehow be possible to achieve such a workflow? Maybe there are already solutions to my specific workflow?


    You should look at pandoc (at least if I understand your question correctly). 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).

    With it you can mix markdown and LaTeX, and then compile to html, tex and pdf. You can also include bibtex references from an external file.

    Some examples (from markdown to latex and 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:

     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.


    Here is an example for 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 . Then you can compile to HTML:

    rst2html example.rst example.html
    

    or to LaTeX:

    rst2latex example.rst example.tex
    

    then compile the resulting LaTeX document:

    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.


    你看过Docutils吗?

    链接地址: http://www.djcxy.com/p/50100.html

    上一篇: 如何在VS2010中指定一个用于转换文件的“自定义工具”?

    下一篇: 将格式化文本(包括源代码)输出为LaTeX,PDF和HTML