Pandoc markdown bold and color

时间秒杀一切 提交于 2020-08-08 18:52:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!