tikzpicture 中 foreach 循环的 \prevdepth 不正确

tikzpicture 中 foreach 循环的 \prevdepth 不正确

我正在尝试修改 ShareLatex 中的名片模板,以便单独制作一张卡片(作为命令)来格式化卡片。然后制作一个 foreach 循环来制作两列卡片。请注意 \singlecard 命令是 OverLeaf 中的卡片模板(版权归各自所有者所有)。

在进行循环时我收到一条错误消息:

<h1>improper \prevdepth.</h1>
\[email protected]@prevdepth=\prevdepth
                         \prevdepth=-1000pt\expan...

=-1000pt=我认为这是添加pdf 时出现的错误

我将这张卡定义为:

\newcommand*{\singlecard}{
    \begin{textblock}{6.5}(0.2,0.2)
        %\noindent
        \textbf{Helena Doe}\\
        \tiny subtitle \hfill {\color{gray}Division / Employer}\\ 
        \rule{3in}{.3mm}\\
        \begin{minipage}[t]{33mm}
            \vspace{-0mm}%
            \includegraphics[height=25mm]{logo}
        \end{minipage}
        \hspace{1mm}
        \begin{minipage}[t]{42mm}
            \vspace{-0mm}%
            \begin{flushleft}
            {\scriptsize
    %            \begin{Spacing}{1}%
                \textbf{Job Title}\\
                \hspace{5mm}Speciality 1\\
                \hspace{5mm}Speciality 2\\
                \hspace{5mm}Speciality 3 \vspace{2mm}\\
    %            \end{Spacing}
            }
            {\tiny
                \begin{tabular}{rl}
                    {\color{gray}web} & https://fqdn/\\
                    {\color{gray}email} & [email protected]\\
                    {\color{gray}email} & [email protected]\\
                    {\color{gray}mobile} & +1 123 456 7890\\
                \end{tabular}
                \vspace*{2mm}
            }
            \end{flushleft}
        \end{minipage}
        \rule{74mm}{0mm}\\
        \texttt{\fontsize{2.84mm}{3.55mm}\selectfont 425B 030A B8D2 0316 CA1B 4709 CA83 5DDA EC31 CA56} % GPG KEY ID
    \end{textblock}
}

我在文件中这样重复一遍:

\begin{tikzpicture}

% grid
\foreach \i in {0,1,2,3,4,5} \draw[very thin, gray,dashed] (0,\i*\cardh) -- (2*\cardw,\i*\cardh);
\foreach \j in {0,1,2} \draw[very thin, gray,dashed] (\j*\cardw,0) -- (\j*\cardw,5*\cardh);
% card content
\foreach \i in {0,1} \foreach \j in {0,1,2,3,4} {
    \node at (\i*\cardw+\i*1,\j*\cardh) {\singlecard};
};
\end{tikzpicture}

以下是用于测试的完整代码:

% BUSINESS CARD template
% created by Karol Kozioł (www.karol-koziol.net)
% for ShareLaTeX - online LaTeX editor (www.sharelatex.com)
% May 2013

\documentclass[10pt]{letter}
\usepackage[dvips]{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{fontawesome}
\usepackage{standalone}
\RequirePackage[showboxes]{textpos}

\usepackage{geometry}
\geometry{
    letterpaper,
    total={8.5in,11in},
    left=0.5in,
    top=0.5in,
}

\pagestyle{empty}

\renewcommand\familydefault{\sfdefault}
\usepackage{tgadventor}

%%% BUSINESS CARD SIZE
\newlength{\cardw}
\newlength{\cardh}
%% ISO 7810 size: 85.60mm × 53.98mm
%\setlength{\cardw}{85.60mm}
%\setlength{\cardh}{53.98mm}
%% European size: 85mm × 55mm
%\setlength{\cardw}{85mm}
%\setlength{\cardh}{55mm}
%% US size: 3.5 in × 2 in
\setlength{\cardw}{3.5in}
\setlength{\cardh}{2in}

\definecolor{maingreen}{HTML}{008000}

% Command for printing the contact information icons
\newcommand*\icon[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1pt, fill=maingreen,maingreen,text=white] (char) {#1};}}

%%% DEFINE USER DATA
\newcommand{\Name}{
{\huge \textbf{Joe Doe}}
}%
\newcommand{\Description}{
{\large CEO of XYZ Company}
}%
\newcommand{\Email}{
[email protected]
}%
\newcommand{\Phone}{
+44 123456789
}%
%%%
% \textsc{\icon{\faLinkedin}} & \underline{\href{http://www.linkedin.com/in/\cvlinked}{\cvlinked}}
\newcommand*{\singlecard}{
    \begin{textblock}{6.5}(0,0)
        %\noindent
        \textbf{Helena Doe}\\
        \tiny subtitle \hfill {\color{gray}Division / Employer}\\ 
        \rule{3in}{.3mm}\\
        \begin{minipage}[t]{33mm}
            \vspace{-0mm}%
            \includegraphics[height=25mm]{logo}
        \end{minipage}
        \hspace{1mm}
        \begin{minipage}[t]{42mm}
            \vspace{-0mm}%
            \begin{flushleft}
            {\scriptsize
    %            \begin{Spacing}{1}%
                \textbf{Job Title}\\
                \hspace{5mm}Speciality 1\\
                \hspace{5mm}Speciality 2\\
                \hspace{5mm}Speciality 3 \vspace{2mm}\\
    %            \end{Spacing}
            }
            {\tiny
                \begin{tabular}{rl}
                    {\color{gray}web} & https://fqdn/\\
                    {\color{gray}email} & [email protected]\\
                    {\color{gray}email} & [email protected]\\
                    {\color{gray}mobile} & +1 123 456 7890\\
                \end{tabular}
                \vspace*{2mm}
            }
            \end{flushleft}
        \end{minipage}
        \rule{74mm}{0mm}\\
        \texttt{\fontsize{2.84mm}{3.55mm}\selectfont 425B 030A B8D2 0316 CA1B 4709 CA83 5DDA EC31 CA56} % GPG KEY ID
    \end{textblock}
}

\begin{document}

    \begin{tikzpicture}


        % grid
        \foreach \i in {0,1,2,3,4,5} \draw[very thin, gray] (0,\i*\cardh) -- (2*\cardw,\i*\cardh);
        \foreach \j in {0,1,2} \draw[very thin, gray] (\j*\cardw,0) -- (\j*\cardw,5*\cardh);
        % card content
        \foreach \i in {0,1} \foreach \j in {0,1,2,3,4} {
            \node at (\i*\cardw,\j*\cardh + \cardh) {\singlecard};
        };

    \end{tikzpicture}

\end{document}

输出结果如下: tex 文件的输出

答案1

该错误意味着您处于水平模式,您可以\prevdepth通过声明来禁用

  \dimendef\prevdepth=0

\prevdepth在本地创建别名的卡之前\dimen0

相关内容