我尝试使用 soul 和 xcolor 来突出显示部分文本,但正如您在图像中看到的,它似乎没有覆盖整个文本。
这条线是Service agents must be able to \hl{\mbox{create}} an account
如果我尝试删除 mbox,它将变成Service agents must be able to \hl{create} an account
如下所示:
我该如何修复这个问题以便它覆盖整个文本?
文档:
%Preamble
\usepackage{pdfpages}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{color}
\usepackage{xcolor}
\usepackage{float}
\usepackage{soul}
% Main.tex
\documentclass[a4paper,twoside,11pt]{report}
\input{Setup/Statics.tex}
\input{Setup/Preamble.tex}
\input{Setup/Settings.tex}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{arabic}
\input{Chapters/06_Design}
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printbibliography[title={Bibliography}]
\clearpage
\appendix
\input{Backmatter/Appendix.tex}
\cleartoleftpage
\end{document}
% Inside Design document
\begin{longtable}{|p{1cm}|p{4cm}|p{10cm}|}
\caption{Noun and verb analysis}
\hline
ID & Requirement & Description \\ \hline
\textbf{FR1} & Create account & Service agents must be able to \hl{create} an account \\ \hline
\end{longtable}
%Settings.tex
% Colours!
\newcommand{\targetcolourmodel}{cmyk}
\selectcolormodel{\targetcolourmodel}
\definecolor{dtured} {rgb/cmyk}{0.6,0,0 / 0,0.91,0.72,0.23}
\definecolor{blue} {rgb/cmyk}{0.1843,0.2431,0.9176 / 0.88,0.76,0,0}
\definecolor{brightgreen}{rgb/cmyk}{0.1216,0.8157,0.5098 / 0.69,0,0.66,0}
\definecolor{navyblue} {rgb/cmyk}{0.0118,0.0588,0.3098 / 1,0.9,0,0.6}
\definecolor{yellow} {rgb/cmyk}{0.9647,0.8157,0.3019 / 0.05,0.17,0.82,0}
\definecolor{orange} {rgb/cmyk}{0.9882,0.4627,0.2039 / 0,0.65,0.86,0}
\definecolor{pink} {rgb/cmyk}{0.9686,0.7333,0.6941 / 0,0.35,0.26,0}
\definecolor{grey} {rgb/cmyk}{0.8549,0.8549,0.8549 / 0,0,0,0.2}
\definecolor{red} {rgb/cmyk}{0.9098,0.2471,0.2824 / 0,0.86,0.65,0}
\definecolor{green} {rgb/cmyk}{0,0.5333,0.2078 / 0.89,0.05,1,0.17}
\definecolor{purple} {rgb/cmyk}{0.4745,0.1373,0.5569 / 0.67,0.96,0,0}
\definecolor{verde} {rgb}{0.25,0.5,0.35}
\definecolor{jpurple} {rgb}{0.5,0,0.35}
\definecolor{darkgreen} {rgb}{0.0, 0.2, 0.13}
\colorlet{frontbackcolor}{blue}
答案1
问题是由于旧版本soul
与xcolor
软件包不兼容而发生的如这里所述. 更新相关软件包至最新版本即可解决该问题。
或者,您可以在加载包后立即添加以下代码soul
:
\usepackage{etoolbox}
\makeatletter
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\newdimen\SOUL@dimen
\makeatother
至于您的代码,请注意您需要添加\\
至于您的代码,请注意,如果您想排版表格上方的标题,则\caption{}
在环境中添加。因此,要提供完整且可编译的 MWE:longtable
\documentclass{report}
%Preamble
\usepackage{longtable}
\usepackage{xcolor}
\usepackage{soul}
%%%%% the following is not needed with an up-to-date version of the `soul` package
\usepackage{etoolbox}
\makeatletter
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\patchcmd{\SOUL@ulunderline}{\dimen@}{\SOUL@dimen}{}{}
\newdimen\SOUL@dimen
\makeatother
%%%%%
% Colours!
\newcommand{\targetcolourmodel}{cmyk}
\selectcolormodel{\targetcolourmodel}
\definecolor{yellow} {rgb/cmyk}{0.9647,0.8157,0.3019 / 0.05,0.17,0.82,0}
\begin{document}
% Inside document
\begin{longtable}{|p{1cm}|p{4cm}|p{10cm}|}
\caption{Noun and verb analysis}\\
\hline
ID & Requirement & Description \\ \hline
\textbf{FR1} & Create account & Service agents must be able to \hl{create} an account \\ \hline
\end{longtable}
\end{document}