如何避免定义的文本和逗号之间出现空格字符?

如何避免定义的文本和逗号之间出现空格字符?

如何避免定义的文本和逗号之间的空格字符?参见蓝色箭头。TeX 代码的输出

\documentclass{article}
\usepackage[USenglish]{babel}
\usepackage{xcolor}
\newcommand{\cst}{\colorbox{white}{\textcolor{red}{\textsf{Quelle Universum AX1}}}}
\begin{document}
Call this think, say, \cst, and do other thinks like runing LATEX. Have a look at the output.
The output looks ne, so perhaps one of the other packages you have loaded has caused the problem. One by one try each of the packages you have in \cst problem document, in the
same order. If adding the package has no effect on the output,
\end{document}

答案1

如果您并非绝对需要框,请按照 Draggluon 的建议将其删除。但是,如果您需要保留它,关键是将其设置\fboxsep0pt,范围使其不会影响文档中的任何其他框。\fboxsep定义在将内容封闭在框中之前在内容周围添加的缓冲空间。如果在调用后想要实际空间,还需要与添加的空组一起使用\cst{}

\documentclass{article}
%\usepackage[USenglish]{babel}
\usepackage{xcolor}
\newcommand{\cst}{{\fboxsep=0pt\colorbox{white}{\textcolor{red}{\textsf{Quelle Universum AX1}}}}}
\begin{document}
Call this think, say, \cst, and do other thinks like runing LATEX. Have a look at the output.
The output looks ne, so perhaps one of the other packages you have loaded has 
caused the problem. One by one try each of the packages you have 
in \cst{} problem document, in the
same order. If adding the package has no effect on the output,
\end{document}

在此处输入图片描述

为什么保留方框很重要?如果您的背景颜色不是白色,或者方框覆盖了其下方的某些内容。

在此处输入图片描述

如果不\fboxsep重置0pt,我们可以看到不需要的空间来自哪里:

在此处输入图片描述

答案2

您正在制作一个框,这是额外的空间。{\colorbox{white}在命令中删除。

\newcommand{\cst}{\textcolor{red}{\textsf{Quelle Universum AX1}}}

在此处输入图片描述

相关内容