这是输出pdflatex
:
相关的 LaTeX 行是:
You can similarly enable the third and fourth channel by giving \texttt{HIGH} input to \icpin{9}{EN3,4}.
以下是我定义\icpin
命令的方式:
\newcommand{\icpin}[2]{\setlength{\fboxsep}{0pt} \fbox{\texttt{\colorbox{lgray}{\strut{}\,PIN~#1\,}\,#2\,}} \setlength{\fboxsep}{2pt}}
我猜问题出在我定义的命令上。如何强制换行符不在句点之前出现?
我尝试\@
在期限后使用,但问题并未解决。
答案1
您给出的定义有两个空格,您应该删除它们
\newcommand{\icpin}[2]{\setlength{\fboxsep}{0pt} \fbox{\texttt{\colorbox{lgray}{\strut{}\,PIN~#1\,}\,#2\,}} \setlength{\fboxsep}{2pt}}
^ ^
以下是正确格式的,但有一些变化:
\newcommand{\icpin}[2]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\fbox{%
\ttfamily
\colorbox{lgray}{\strut\,PIN~#1\,}\,#2\,%
}%
\endgroup
}
该组将设置设为\fboxsep
本地设置,因此您无需明确重置它。使用\ttfamily
可避免使用另一对括号:该组将限制此声明的效果。
完整代码:
\documentclass{article}
\usepackage{xcolor}
\definecolor{lgray}{gray}{0.7}
\newcommand{\icpin}[2]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\fbox{%
\ttfamily
\colorbox{lgray}{\strut\,PIN~#1\,}\,#2\,%
}%
\endgroup
}
\begin{document}
You can similarly enable the third and fourth channel
by giving \texttt{HIGH} input to \icpin{9}{EN3,4}.
\end{document}
也许您还应该在两端添加一些细小的空间。
\documentclass{article}
\usepackage{xcolor}
\definecolor{lgray}{gray}{0.7}
\newcommand{\icpin}[2]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\leavevmode\,% <-- don't forget \leavevmode
\fbox{%
\ttfamily
\colorbox{lgray}{\strut\,PIN~#1\,}\,#2\,%
}%
\,%
\endgroup
}
\begin{document}
You can similarly enable the third and fourth channel
by giving \texttt{HIGH} input to \icpin{9}{EN3,4}.
\end{document}
答案2
删除\,
和多余的空格似乎使句号附加到框上。这是一个之前和后图像:
代码:
\documentclass{article}
\usepackage{xcolor}
\newcommand{\icpin}[2]{%
\setlength{\fboxsep}{0pt}%
\fbox{\texttt{\colorbox{gray}{\strut{}\,PIN~#1\,}\,#2}}%
\setlength{\fboxsep}{2pt}%
}%
\begin{document}
You can similarly enable the third and fourth channel by giving \texttt{HIGH} input to \icpin{9}{EN3,4}.
\end{document}