Pandoc Markdown粗体和颜色 [英] Pandoc markdown bold and color

查看:284
本文介绍了Pandoc Markdown粗体和颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pandoc,并在markdown中写入文字.为了创建自己的样式,我使用了自定义的乳胶模板.

I am using pandoc and write my text in markdown. To create my own style I use a custom latex template.

我想为所有粗体字设置颜色.因此,当我键入**a word**时,该单词不仅应为粗体,而且应为蓝色.

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}

使用转换为pdf时给我一个错误

gives me an error when converting to pdf using

pandoc myfile -f markdown -t latex --template==mytemplate -o myfile.pdf

其中

超出了TeX的容量,抱歉(分组级别= 255)

TeX capacity exceeded, sorry (grouping levels = 255)

但是:当我只设置新命令时

However: when I only set the newcommand

\newcommand\boldblue[1]{\textcolor{blue}{\textbf{#1}}}

我可以在我的markdown文件中写入$\boldblue{some text}$,它可以工作.

I can write $\boldblue{some text}$ within my markdown file and it works.

问题:如何为**<word>**设置新命令?

Question: how do I set a new command for **<word>**?

谢谢!

推荐答案

经过更多研究,我发现使用\let的以下解决方案有效:

After some more research I found the following solution using \let which works:

\let\oldtextbf\textbf
\renewcommand\textbf[1]{{\color{blue}\oldtextbf{#1}}}

在模板文件中使用此代码会将markdown的**<some text>**转换为乳胶/pdf中的粗体和蓝色.

Using this code in a template file converts markdown's **<some text>** to bold and blue in latex / pdf.

这篇关于Pandoc Markdown粗体和颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆