[Tex/LaTex] Pandoc LaTeX to .docx, change font size

pandoc

I am using Pandoc to convert a LaTeX document to .docx, but i have not been able to figure out how to change the font size. An MWE looks like this

\documentclass[10pt]{article}
\begin{document}
Hello world
\scriptsize
Hello world
\end{document}

Compiling the MWE with pdflatex produces an output where the two "Hello world" statements appear in different font sizes. Converting with pandoc, i get a document where both statements have the same font size. How do i get them to appear in different sizes in the word document?

Best Answer

Pandoc supports only a small subset of LaTeX commands and \scriptsize is not one of them. Why does it work anyway? Because unrecognized LaTeX (or ConTeXt or HTML) commands are passed unchanged to the LaTeX (or ConTeXt or HTML) writer. If you want to use pandoc to convert LaTeX to .docx, then you should stick to those commands that can be represented in pandoc's own markdown format.

Nevertheless: If you want to modify the produced .docx you can save the reference file using: pandoc --print-default-data-file reference.docx > custom-reference.docx

In custom-reference.docx you can change the following styles (be sure to actually change the style defined in the document, not just the sample text!):

paragraph

  • Normal
  • Body Text
  • First Paragraph
  • Compact
  • Title
  • Subtitle
  • Author
  • Date
  • Abstract
  • Bibliography
  • Heading 1
  • Heading 2
  • Heading 3
  • Heading 4
  • Heading 5
  • Heading 6
  • Block Text
  • Footnote Text
  • Definition Term
  • Definition
  • Caption
  • Table Caption
  • Image Caption
  • Figure
  • Figure With Caption
  • TOC Heading

character

  • Default Paragraph Font
  • Body Text Char
  • Verbatim Char
  • Footnote Reference
  • Hyperlink

table

  • Normal Table

You can use the changed reference file by adding the option --reference-doc=custom-reference.docx.

Related Question