Hot answers tagged

80

With pandoc 1.12.x and it’s new YAML metadata capabilities you could add all the information and all LaTeX-code you need in your markdown document like this: --- title: Test author: Author Name header-includes: | \usepackage{fancyhdr} \pagestyle{fancy} \fancyhead[CO,CE]{This is fancy} \fancyfoot[CO,CE]{So is this} \fancyfoot[LE,RO]{\...


53

The writer.latex file in Pandoc's source code currently defines \tightlist as: \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} This is also currently the case in the default LaTeX template, from the jgm/pandoc-templates project on Github. For posterity, here is a link to the most up-to-date LaTeX default template: ...


49

I tried nearly all methods mentioned in other answers. Eventually, and surprisingly, I found the most satisfactory way to convert is to just open the PDF file in MS Word (2013 or newer), which retained most of the layout. Although you are gonna lose the hyperlinks of cross-references.


37

(See Update at the end, to get proper colors) By default pandoc uses its own highlighting engine, but it can be changed to use package listings instead. Simply add --listings option to your pandoc command line. However, the format used by listings does not break long lines either, but you can prepare all the required options in a separate tex file, for ...


33

The basic problem you're running into is the immaturity of the epub format. It's very easy for a publisher to produce an epub 3 of a novel if they're already set up to produce epub 2, and the epub 3 version will typically work fine on readers designed for epub 2. However, there seems to have been very slow progress to date on getting publishers and device ...


31

I gave up on pandoc for almost exactly the same reasons you listed. If you are set on using pandoc, the simplest solution may be to just identify environments and packages that cause trouble - and then not use them, or just type the offending stuff directly in to MS Word. I've had a fair amount of luck with going to word documents using latex2rtf to create ...


29

It has always been a possibility although obviously the document markup side of latex is mostly aimed at hand authored documents, but even back while 2e was being developed there were wysiwyg systems like sw that are essentially generating latex that isn't touched and latex is often used for typesetting from XML (or previously SGML) using xslt or dsssl or ...


24

Beside writing a custom template, you can add code to the header using --include-in-header=FILENAME: % filename: fontoptions.tex \setmainfont[ BoldFont = Font-Bold.otf, ItalicFont = Font-Italic.otf, BoldItalicFont = Font-BoldItalic.otf ]{Font-Regular.otf} and call: $ pandoc --pdf-engine=xelatex --include-in-header=fontoptions.tex input.md -o output.pdf ...


23

You can pass the lang option to the template using -V which passes it further to the babel package. pandoc -V lang=dutch somefile.markdown This is translated to the following LaTeX code which should result in dutch chapter headings. \usepackage[dutch]{babel}


20

You could redefine \item so that it reads the stuff between [ ] as horizontal box, which can hold verbatim. For this you need to scan for the beginning [, start the box storing process and make ] an active character (i.e. like a macro) which adds the end of the box and call the original \item with the box as argument. Tell me if you need further help ...


19

I hit the same problem. It seems that pandoc started using \tightlist in \begin{itemize} sections. My workaround was simply to add an empty macro for \tightlist to my template file (I run pandoc with --template=mytemplate.tex): \def\tightlist{}


18

Pandoc cannot use a template provided as a *.csl file to style its DOCX output. If you want to get Pandoc using a specific set of styles, you need to create (or grab) another DOCX file containing these styles. Note, that the style names do need to conform to the standard names in the first place. (In the past I've succeeded to let it use non-standard style ...


17

pandoc cannot convert a .bib file into another file format1. However, it can convert a .tex file which contains references (called from a .bib file) into a pdf, odt, html, ... If your .tex file just contains the \nocite{*} command, the result is similar (you will have all your references printed). Here is the magic command: pandoc test.tex -o output.odt --...


17

The --biblatex option only applies to LaTeX. When I tried pandoc --bibliography=foo.bib -o foo.docx foo.tex it worked for me. If you want Chicago you need to add an option for that e.g. --csl=chicago-author-date.csl. You can get the CSL file from github.com/citation-style-language/styles.


16

LaTeX2rtf is the easiest and fastest way to convert .tex files to .rtf that can be read by Microsoft Word. Using it is as simple as downloading the program, choosing your .tex file, and pressing run. A command window will open up to display the progress and warn of any errors. In most cases the default settings will be sufficient and despite errors it can ...


16

If you want to use citations, you also have to define the CSL-style (Citation Style Language) to be used, via a *.csl-file you have to reference. Here is an MWE in Markdown. It tests a few different methods to provide references to citations in Markdown: # Markdown source code for relevant part of this page ``` {.markdown} i. [@nonexistent] i. @...


15

A simple solution is to add a line with a backslash and space immediately after the figure, followed by a blank line: ![Alt text](image.png) \ Some text after the figure... Do not forget the space after the backslash! This seems to work on Pandoc 1.12.4.2. Edit: as pointed out in the comments, this will suppress figure captions.


15

Still offtopic but you can print the default template with pandoc -D latex, edit it and put it in your personal data directory ($HOME/.pandoc on linux): pandoc -D latex > ~/.pandoc/default.latex && $EDITOR ~/.pandoc/default.latex All of this is documented here: http://pandoc.org/README.html


14

You have told your editor that the file is stored as latin1 encoding % !TeX encoding = ISO-8859-1 But pandoc thinks it is reading a UTF-8 encoded file so can not decode it. These encodings are the same for ascii letters but differ for anything else. Pandoc may have an option to tell it the file encoding or if not, you should get your editor to save the ...


14

Nevermind, I found a way to do it. I was using the builtin code highlighter. Setting the --listings flag, I can switch to the lstlistings package and use the following syntax: ~~~~{caption="The preprocessing step" label=lstpreprocess} def myfunction(var): """ Oh how awesome this is. """ pass ~~~~ Pandoc is awesome.


14

The solution is to use a CSL file to format the citations. I used ieee.csl from https://github.com/citation-style-language/styles pandoc -s foo.tex --bibliography=foo.bib --csl=ieee.csl -o foo.docx


13

(This is really a comment on Ben's answer but is a bit long.) Broadly I agree with what Ben has said about the current state of play. The outlook is a bit gloomy. However, I think that there are a couple of glimmers of light that give me a little hope for some progress to occur. As Ben says, ePub is quite like XHTML. So if you can produce a valid XHTML+...


13

This is most likely because the figure environment floats, which is not what you're after. For this you have a couple of options: Add the float package which provides the H float specifier, allowing you to use \usepackage{float}% http://ctan.org/pkg/float %... \begin{figure}[H] %... \caption[<ToC>]{<regular>} \end{figure} stopping the float ...


13

An extension exists on github: pandoc-crossref install it with cabal update cabal install pandoc-crossref or in archlinux using ArchHaskell pacman -Sy pandoc-crossref you can use it by doing $$ math $$ {#eq:label} [@eq:label] and compiling with pandoc file.md --filter pandoc-crossref -o file.pdf for more information see the documentation ...


13

As of pandoc-citeproc-0.4 pandoc-citeproc has support for a \nocite{*}-equivalent. mybib.bib file: @article{behbahani2014aircraft, title={Aircraft Integration Challenges and Opportunities for Distributed Intelligent Control, Power, Thermal Management, Diagnostic and Prognostic Systems}, author={Behbahani, Alireza R and Von Moll, Alexander and ...


12

I'm not sure you want to read this. If you are forced to use MS Word for your work then better use Word to write it. LaTeX typesetting is much better than Word can do. So every conversion from LaTeX to Word will disappoint you about the quality of the conversion---if possible. Why do you want to do the same "work" two times: first writing your script in ...


12

Pandoc's LaTeX importer may not handle every input very well, but when you go via Pandoc's markdown format, which maps basically one-to-one to Pandoc's internal document representation, you have precise control over the output. Convert .tex to markdown: pandoc document.tex -o document.md Manually clean up the generated markdown file. Pandoc's extended ...


11

Maybe you need this answer. \documentclass{standalone} \usepackage{arev} \begin{document} $\heartsuit$ \end{document}


11

I write my APA6th papers with LaTeX and export them with all beauty to PDF. Normally this is all I need. Sometimes publisher ask for word files (the reason why I don't know...). So I was on the search to a decent pdf to word converter since simpletex4th has table issues and I need tables a lot. The only converter I am satisfied with is PDF to Word + by ...


11

After some more experiments and reading documentation I am pretty sure there is no way to avoid creating an intermediate Latex file if one wants to use native Latex citation and bibliography power. The reason is with Pandoc we can apparently use one of two possible techniques to produce bibliographic references: Either CSL files (with the --csl setting) or ...


Only top voted, non community-wiki answers of a minimum length are eligible