[英]How can I highlight `\cite` (linebreak preserving) in latex
我怎樣才能像這樣突出顯示(設置背景顏色) \cite
(保留換行符): [1]
當我在 package soul
中嘗試\hl
時出現編譯錯誤,例如:
\hl{\cite{xxx}}
\mobx
可以解決這個問題,但不支持換行符。
我也試過\colorbox
和\newcommand\hl{\bgroup\markoverwith {\textcolor{GhostWhite}{\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}
參考書目:
@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}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.