我想模仿意大利公投表,其中有两个矩形框,分别包含“Sì”和“No”。我写了以下代码:
% !TeX program = lualatex
\documentclass[margin = 0.5cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[anchor = base] node [%
minimum size = 1.5cm, draw, inner sep = 2.5pt, fill = white, %
thick, scale = 2] at (5,4) {\Huge \textsc{Sì}} %
node [minimum size = 1.5cm, draw, inner sep = 2.5pt, fill = white, %
thick, scale = 2] at (15,4) {\Huge \textsc{No}};
\draw[red, ultra thick] (3,4) -- (18,4) (3,5.3) -- (18,5.3) %
(3,6) -- (18,6) (3,3) -- (18,3);
\end{tikzpicture}
\end{document}
正如红线所示,虽然单词对齐了,但周围的“方框”却没有对齐。我该如何避免这种情况?
答案1
您可以设置text height
并text depth
:
\documentclass[margin = 0.5cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[anchor = base] node [%
minimum size = 1.5cm, text height=2em, text depth=.15em, draw, inner sep = 2.5pt, fill = white, %
thick, scale = 2] at (5,4) {\Huge \textsc{Sì}} %
node [minimum size = 1.5cm, text height=2em, text depth=.15em, draw, inner sep = 2.5pt, fill = white, %
thick, scale = 2] at (15,4) {\Huge \textsc{No}};
\draw[red, ultra thick] (3,4) -- (18,4) (3,5.3) -- (18,5.3) %
(3,6) -- (18,6) (3,3) -- (18,3);
\end{tikzpicture}
\end{document}