我想定义一个LaTeX命令,在每个字母后插入一个空格.
所以,如果我补充一下
\addSpaces{someText}
Run Code Online (Sandbox Code Playgroud)
结果应该是
s o m e T e x t
Run Code Online (Sandbox Code Playgroud)
我怎么能实现这个目标?
背景:我希望每个字母都加下划线,但这些字母应该在字母之间分开:
s o m e T e x t
_ _ _ _ _ _ _ _
NOT:
s o m e T e x t
_______________
Run Code Online (Sandbox Code Playgroud)
您可以使用灵魂包来添加下划线。对于单个单词,您可以使用\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}
Run Code Online (Sandbox Code Playgroud)