问题
I am using pandoc and write my text in markdown. To create my own style I use a custom latex template.
I want to style all bold words with a color. So when I type **a word**
this word should not only be bold, but also e.g. blue.
Using the following in my latex template file
\newcommand\boldblue[1]{\textcolor{blue}{\textbf{#1}}}
\renewcommand{\textbf}{\boldblue}
gives me an error when converting to pdf using
pandoc myfile -f markdown -t latex --template==mytemplate -o myfile.pdf
which says
TeX capacity exceeded, sorry (grouping levels = 255)
However: when I only set the newcommand
\newcommand\boldblue[1]{\textcolor{blue}{\textbf{#1}}}
I can write $\boldblue{some text}$
within my markdown file and it works.
Question: how do I set a new command for **<word>**
?
Thanks!
回答1:
After some more research I found the following solution using \let
which works:
\let\oldtextbf\textbf
\renewcommand\textbf[1]{{\color{blue}\oldtextbf{#1}}}
Using this code in a template file converts markdown's **<some text>**
to bold and blue in latex / pdf.
来源:https://stackoverflow.com/questions/52384665/pandoc-markdown-bold-and-color