我想定义一个 LaTeX 命令,在每个字母后插入一个空格。
所以,如果我添加
\addSpaces{someText}
结果应该是
s o m e T e x t
我怎么能做到这一点?
背景:我希望每个字母都带有下划线,但该行应该在字母之间分开:
s o m e T e x t
_ _ _ _ _ _ _ _
NOT:
s o m e T e x t
_______________
最佳答案
您可以使用 soul package用于下划线。对于单个单词,您可以使用 \addspaces
我在下面写的宏。 (宏会吞掉单词之间的空格。一个简单的解决方法是使用\quad 来增加单词之间的空格。)
\documentclass{article}
\usepackage{soul}% provides underlining
\makeatletter% since we're using a macro containing @
\newcommand{\addspaces}[1]{%
\@tfor\letter:=#1\do{%
\ul{\letter}\space
}%
}
\makeatother% resets @ to its original meaning
\begin{document}
% Works fine for single words
\addspaces{Spaces}
% Note that spaces in between words aren't preserved -- use \quad to add extra space.
\addspaces{Spaced\quad and\quad underlined.}
\end{document}
关于LaTeX:每个字母后的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3951392/