pandoc

Pandoc: Different outputs to docx and LaTeX formats


In LaTeX one could for example have a nice inline equation like $x^2=4$, which in docx format I would be glad to have as italic text. Is there a way to tell Pandoc to use one of these solutions depending on the output format?
When searching for a possible solution, I realized pandoc has filters and templates. I would not really understand, which direction to follow.
But I would really like to arrive with a more general solution, that would also work for analogous tasks like, for example, smaller spaces between a number and units: In LaTeX straightforward $\;$, but including this in my Markdown document would not give me a satisfactory result in DOCX or ODT output.


Solution

  • This is what I found from the pandoc manual

    For docx output, styles will be defined in the output file as inheriting from normal
    text, if the styles are not yet in your reference.docx. If they are already defined,
    pandoc will not alter the definition.
    

    and please read the --reference-doc=FILE part of the maunal

    --reference-doc=FILE
    Use the specified file as a style reference in producing a docx or ODT file.
    ...
    

    how to use the reference-doc in pandoc???

    1. create a empty docx file and rename it (eg. refer.docx)
    2. define the styles you want to display
    3. add "--reference-doc=(refer.docx path)" into your pandoc command line .