我想绘制一个TikZ
有两列的表格,左列包含从 A 到 Z 的字母,右列包含相应的字母dancer
。我使用的代码是:
\documentclass[a4paper, 12pt,landscape]{article}
\usepackage[vmargin={1cm,1cm},hmargin={8mm,1cm}]{geometry}
\usepackage{lmodern}
\usepackage{tikz}
\DeclareFontFamily{OT1}{dancers}{}
\DeclareFontShape{OT1}{dancers}{m}{n}{<-> dancers}{}
\newcommand{\dancers}[1]{%
\usefont{OT1}{dancers}{m}{n}\spaceskip=5pt
#1}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[
box/.style={draw, minimum size=7mm}]
\foreach \i [count=\ni from 0] in {A,B,...,Z}{
\node[box] at (0,-\ni*7mm) {\i};
\node[box] at (7mm,-\ni*7mm) {\dancers{\i}};
}
\end{tikzpicture}
\end{document}
结果细节如下:
如您所见,对齐效果不是很好。我该如何做得更好?我想保留节点大小,但最好dancer
将其居中。有什么想法吗?
答案1
\smash{\raisebox{-8pt}{}}
应用简单的\dancers{}
。
如果不使用\smash
,您可以将每个字形降低多达 12pt,然后垂直范围才会超出字形空间的底部,并破坏图表的外观。
这些字形位于基线以上如此高的位置确实显得不寻常(也许它们在跳舞时正在跳跃 ;^)
\documentclass[a4paper, 12pt,landscape]{article}
\usepackage[vmargin={1cm,1cm},hmargin={8mm,1cm}]{geometry}
\usepackage{lmodern}
\usepackage{tikz}
\DeclareFontFamily{OT1}{dancers}{}
\DeclareFontShape{OT1}{dancers}{m}{n}{<-> dancers}{}
\newcommand{\dancers}[1]{%
\usefont{OT1}{dancers}{m}{n}\spaceskip=5pt
#1}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[
box/.style={draw, minimum size=7mm}]
\foreach \i [count=\ni from 0] in {A,B,...,Z}{
\node[box] at (0,-\ni*7mm) {\i};
\node[box] at (7mm,-\ni*7mm) {\smash{\raisebox{-8pt}{\dancers{\i}}}};
}
\end{tikzpicture}
\end{document}