如何在latex中突出显示“\cite”(保留换行符)
如何突出显示(设置背景色)如何在latex中突出显示“\cite”(保留换行符),latex,Latex,如何突出显示(设置背景色)\cite(保留换行符)如下:[1] 当我在包soul中尝试\hl时,我遇到了一个编译错误,比如: \hl{\cite{xxx}} \mobx可以修复此问题,但不支持换行 我还尝试了\colorbox和\newcommand\hl{\bgroup\markoverwith{\textcolor{ghostwite}{\rule[-.5ex]{2pt}{2.5ex}}\ULon},但它们也不支持换行 编译错误示例 main.tex: \documentclass{art
\cite
(保留换行符)如下:[1]
当我在包soul
中尝试\hl
时,我遇到了一个编译错误,比如:
\hl{\cite{xxx}}
\mobx
可以修复此问题,但不支持换行
我还尝试了\colorbox
和\newcommand\hl{\bgroup\markoverwith{\textcolor{ghostwite}{\rule[-.5ex]{2pt}{2.5ex}}\ULon}
,但它们也不支持换行
编译错误示例
main.tex:
\documentclass{article}
\usepackage{soul}
\begin{document}
\hl{{\cite{c1, c2, c3}}}
\bibliographystyle{plain}
\bibliography{ref}
\end{document}
参考bib:
@book{c1,
...
}
@book{c2,
...
}
@book{c3,
...
}
我的问题
- 突出显示
\cite
\cite
宏包装到另一组花括号中:
\documentclass{article}
\begin{filecontents*}[overwrite]{\jobname.bib}
@book{knuth,
author = {Knuth, Donald E.},
title = {The {\TeX} book},
date = 1984,
maintitle = {Computers \& Typesetting},
volume = {A},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
langid = {english},
langidopts = {variant=american},
sortyear = {1984-1},
sorttitle = {Computers & Typesetting A},
indexsorttitle= {The TeXbook},
indextitle = {\protect\TeX book, The},
shorttitle = {\TeX book}
}
\end{filecontents*}
\usepackage{soul}
\begin{document}
\hl{{\cite{knuth}}}
\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}
对于多个引用,可以将它们包装在\mbox{…}
中(这将失去换行的功能),也可以使用lualatex:
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{lua-ul,luacolor}
\begin{filecontents*}[overwrite]{\jobname.bib}
@book{c1,
...
}
@book{c2,
...
}
@book{c3,
...
}
\end{filecontents*}
\begin{document}
\underLine{\cite{c1, c2, c3}}
\highLight{\cite{c1, c2, c3}}
\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}
请制作一个而不是此代码片段谢谢您的建议!如果我只引用一篇论文/一本书,它就能正常工作。当我
\cite
一次引用多篇论文/书籍时,例如:\hl{{\cite{foo,bar,foobar}}
,我得到一个错误:!软件包灵魂错误:重建失败。
和一个黑色正方形,如█ 在pdf中file@KimbingNg同样,请不要只显示代码片段,制作一个复制错误的示例好的,我编辑了我的问题描述,并在那里添加了一个可复制的示例。