我想定义一个LaTeX命令,在每个字母后插入一个空格。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
_______________
我想定义一个LaTeX命令,在每个字母后插入一个空格。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
宏。 (宏将吞字与字之间的空间。一个简单的解决方法是使用\四,增加单词之间的空格。)
\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}
对于文本的程序操作,我觉得它更容易使用perltex定义perl函数来执行代码然后编译文档。请参阅CTAN。
这是一个快速和肮脏。
\documentclass{article}
\usepackage{perltex}
\perlnewcommand{\ulspace}[1]{
$input = shift;
$input =~ s/(\w)/\\underline\{\1\} /g;
return $input;
}
\begin{document}
\ulspace{Hello World}
\end{document}
编译:
perltex --latex=pdflatex myfile.tex
所以......没的其中之一锻炼你吗?仍然有麻烦? – 2010-10-20 14:19:41