对于书籍封面,我想垂直写标题(像日语一样,但使用英文文本):
T
T I
H T
I I M L
S S Y E
我怎样才能做到这一点而不跳过大量的\vbox
和\hbox
?
答案1
\documentclass{article}
\makeatletter
\protected\def\vvv#1{\leavevmode\bgroup\vbox\bgroup\xvvv#1\relax}
\def\xvvv{\afterassignment\xxvvv\let\tmp= }
\def\xxvvv{%
\ifx\tmp\@sptoken\egroup\ \vbox\bgroup\let\next\xvvv
\else\ifx\tmp\relax\egroup\egroup\let\next\relax
\else
%\hbox{\tmp}%original
\hbox to 1.1em{\hfill\tmp\hfill}% centred
\let\next\xvvv\fi\fi
\next}
\makeatother
\begin{document}
\vvv{This is my title}
\end{document}
答案2
将标题按空格分开,然后按字母分开每个单词,并tabular
为每个单词建立一个。然后打印所有这样得到的表格:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xparse}
\ExplSyntaxOn
% variables
\seq_new:N \l_verttext_words_seq
\seq_new:N \l_verttext_singleword_seq
\seq_new:N \l_verttext_final_seq
% user level command
\NewDocumentCommand{\verticaltitle}{m}
{
{\huge\verttext_title:n { #1 }\par}
}
% Inner function
\cs_new_protected:Npn \verttext_title:n #1
{
% clear the sequence holding the final result
\seq_clear:N \l_verttext_final_seq
% split the title at spaces
\seq_set_split:Nnn \l_verttext_words_seq { ~ } { #1 }
% from each word build a tabular
\seq_map_inline:Nn \l_verttext_words_seq
{
% split the word into letters
\seq_set_split:Nnn \l_verttext_singleword_seq { } { ##1 }
% build the tabular for the single word
\seq_put_right:Nx \l_verttext_final_seq
{
\exp_not:n { \begin{tabular}[b]{@{}c@{}} }
\seq_use:Nnnn \l_verttext_singleword_seq { \\ } { \\ } { \\ }
\exp_not:n { \end{tabular} }
}
}
% output the tabulars separated by a \qquad
\seq_use:Nnnn \l_verttext_final_seq { \qquad } { \qquad } { \qquad }
}
\ExplSyntaxOff
\begin{document}
\verticaltitle{THIS IS MY TITL{É}}
\end{document}
请注意,特殊字母必须用括号括起来;对于标题来说没什么大不了的。\arraystretch
如果使用重音字母,您可能需要增加。
答案3
\documentclass{article}
\usepackage{stackengine}
\begin{document}
\Longstack{T H I S}
\Longstack{I S}
\Longstack{M Y}
\Longstack{T I T L E}
~~or~~
\Longstack{T H I S {}}
\Longstack{I S {} {} {}}
\Longstack{M Y {} {} {}}
\Longstack{T I T L E}
\end{document}