TeX - LaTeX Asked by cmhughes on June 14, 2021
I’m using pandoc
to convert from .tex
to .rst
.
If I start with the following .tex
file, mwe.tex
mwe.tex
section{Introduction}
Here is some text.
Here is some more text.
begin{minipage}{.4textwidth}
mycommand{first argument}{second argument}{3rd argument}
end{minipage}%
hfill
begin{minipage}{.4textwidth}
This type of listing is a texttt{.tex} file.
end{minipage}%
and run the following command
pandoc mwe.tex -o mwe.rst
then I receive the output
mwe.rst
Introduction
============
Here is some text.
Here is some more text.
.4
.4 This type of listing is a ``.tex`` file.
I’d like to customize the conversion of the minipage
environment and mycommand
command. How can this be done?
Pandoc can parse latex macro definitions. This means, that you can add dummy newcommand
statements to tweak what will end up in the output:
input file 1: dummy.tex
newcommand{mycommand}[3]{(#1) and (#2) and (#3)}
input file 2: mwe.tex
section{Introduction}
Here is some text.
Here is some more text.
begin{minipage}{.4textwidth}
mycommand{first argument}{second argument}{3rd argument}
end{minipage}%
hfill
begin{minipage}{.4textwidth}
This type of listing is a texttt{.tex} file.
end{minipage}%
run:
pandoc dummy.tex mwe.tex -o mwe.rst
output file mwe.rst:
Introduction
============
Here is some text.
Here is some more text.
(first argument) and (second argument) and (3rd argument)
.. raw:: latex
hfill
This type of listing is a ``.tex`` file.
And, as you can see, more recent versions of pandoc (in this case 2.1.1) handle minipages much better.
You might need to write a filter for more complicated issues.
Correct answer by DG' on June 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP