LaTeX:每个字母后的空格

标签 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我在下面写的宏。 (宏会吞掉单词之间的空格。一个简单的解决方法是使用\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/

相关文章:

latex - 在 Latex 中将页眉/页脚插入章节页面

emacs - 如何使用特定的序言将 Org 模式导出到 LaTeX?

latex - 如何在 Sphinx 中的图像前后插入一些空格

Latex,如何使算法跨越两列文章中的两列

latex - 如何在括号内使用 LaTeX 打印引用?

python - 如何在 latexpdf 输出中使用 Sphinx 获取列表周围的间距?

r - 如何在所有其他代码块之后强制 Knitr 评估\Sexpr

LaTeX - 为整个文档设置小字体

latex - Sympy - 分数操作

latex - 增加竖条的长度