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

I am editing a lot of latex documents that consist of lists of codes and are currently being output in pdf.

Since I work in teams on these documents, I often have to manually integrate the changes made by group members into the latex source.

Most members of the group do not know latex, so I would like to be able to allow them to format the document in a style that may look like markdown.

Since latex documents are made up of numbers, have links, and use the lslisting package, I wonder if these specific areas can be matched with the simple markdown style syntax.

Workflow example:

  • Edit file in Markdown (or similar)
    • tag sections
    • tag code areas
    • tag metrics
    • tag links
  • convert to latex
    • automatically convert tags
  • exit
    • Pdf
    • HTML

How could such a workflow be achieved? Maybe there are already solutions for my specific workflow?

+7
source share
4 answers

You should look at pandoc (at least if I understood your question correctly). It can convert several formats (tex, pdf, word, reStructuredText), and also supports extended versions of the markdown syntax to handle more complex problems (for example, inserting header information in html).

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

Some examples (from markdowns 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 

This is a truly flexible and amazing program, and I use it a lot.

+1
source

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 this as example.rst . Then you can compile HTML:

 rst2html example.rst example.html 

or in 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 several Sphinx sources, which is based on Docutils and focuses on technical documentation.

+2
source

Have you watched Docutils ?

+1
source

If you are an Emacs user, you can find the org-mode markup as you wish. It supports tables very well, coordinates well with other Emacs modes, such as a spreadsheet, and has a good export of images to HTML. Wed is a wonderful HTML export section .

org-mode files are editable outside Emacs, for team members who don't use it, although previewing and embedding other Emacs modes can naturally only be done with Emacs.

0
source

All Articles