第一个 tikz 页面有什么问题?xshift 有几毫米

第一个 tikz 页面有什么问题?xshift 有几毫米

我对用相同函数绘制的一系列页面的第一页遇到了一个奇怪的问题。

我必须承认,我并不真正理解宏和变量以及长度等之间的区别,但代码在原则上是有效的。

第 1 页的内容向右移动 - 仅限第 1 页 - 后面的页面看起来还不错。

有人能解释一下吗?

敬礼 Peter

(该文件是好奇号秀的编织针归档系统的图纸……)

\documentclass[a5paper,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{xstring}

\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{anyfontsize}
\usepackage[scaled]{helvet}
\usepackage{ifthen}

\geometry{a5paper,
 left=0mm,right=0mm,top=0mm,bottom=0mm,
 landscape
}

\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}

\newlength{\width}
\newlength{\xspace}
\newlength{\xoff}
\newlength{\yspace}
\newlength{\csize}
\newlength{\height}
\newlength{\ydelta}
\setlength{\width}{210mm}
\setlength{\height}{148mm}
\setlength{\csize}{5mm}
\setlength{\xspace}{40.25mm}
\setlength{\yspace}{11mm}
\setlength{\xoff}{.5\width}
\addtolength{\xoff}{-1.5\xspace}
\setlength{\ydelta}{\height}
\addtolength{\ydelta}{-\yspace}
\def\ybitset{\ydelta+\height*.5-\ydelta*.5}

\newcommand{\checkpos}[2]{%
  \StrMid{#1}{#2}{#2}[\testchar]
  \ifthenelse{\equal{\testchar}{\string 0}}
    {\def\bitcol{white}}
    {\def\bitcol{black}}%
}

\newcommand{\knfs}[2]{%
\begin{tikzpicture}[x=1mm,y=1mm]
\checkpos{#1}{1}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*0, \ybitset) {};
\checkpos{#1}{2}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*1, \ybitset) {};
\checkpos{#1}{3}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*2, \ybitset) {};
\checkpos{#1}{4}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*3, \ybitset) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*0,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*1,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*2,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*3,\ydelta) {};
\node[draw=none, fit={(0,0) (\width,\height)}, inner sep=0pt, label={[yshift=-20]center:{\fontsize{280}{0}\selectfont #2}}] {};
\end{tikzpicture}}

\begin{document}
\knfs{0001}{1}\\
\knfs{0010}{2}\\
\knfs{0011}{3}\\
\knfs{0100}{4}\\
\knfs{0101}{5}\\
\knfs{0110}{6}\\
\knfs{0111}{7}\\
\knfs{1000}{8}\\
\knfs{1001}{9}\\
\knfs{1010}{10}\\
\knfs{1011}{11}\\
\knfs{1100}{12}\\
\knfs{1101}{13}\\
\knfs{1110}{14}
\end{document}

编辑:经过一些实验以获得后移后,我\hspace*{-5.2mm}\knfs{0001}{1}\\在第一页做了一个简单的操作...结果并不准确 - 但可能足够好。但问题仍然存在...

答案1

更改\knfs{0001}{1}\noindent\knfs{0001}{1},以便删除页面缩进。

更新的代码:

\documentclass[a5paper,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{xstring}

\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{anyfontsize}
\usepackage[scaled]{helvet}
\usepackage{ifthen}

\geometry{a5paper,
 left=0mm,right=0mm,top=0mm,bottom=0mm,
 landscape
}

\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}

\newlength{\width}
\newlength{\xspace}
\newlength{\xoff}
\newlength{\yspace}
\newlength{\csize}
\newlength{\height}
\newlength{\ydelta}
\setlength{\width}{210mm}
\setlength{\height}{148mm}
\setlength{\csize}{5mm}
\setlength{\xspace}{40.25mm}
\setlength{\yspace}{11mm}
\setlength{\xoff}{.5\width}
\addtolength{\xoff}{-1.5\xspace}
\setlength{\ydelta}{\height}
\addtolength{\ydelta}{-\yspace}
\def\ybitset{\ydelta+\height*.5-\ydelta*.5}

\newcommand{\checkpos}[2]{%
  \StrMid{#1}{#2}{#2}[\testchar]
  \ifthenelse{\equal{\testchar}{\string 0}}
    {\def\bitcol{white}}
    {\def\bitcol{black}}%
}

\newcommand{\knfs}[2]{%
\begin{tikzpicture}[x=1mm,y=1mm]
\checkpos{#1}{1}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*0, \ybitset) {};
\checkpos{#1}{2}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*1, \ybitset) {};
\checkpos{#1}{3}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*2, \ybitset) {};
\checkpos{#1}{4}
\node[rectangle, fill=\bitcol!25, draw=none, minimum width = \csize, minimum height = \yspace] at (\xoff+\xspace*3, \ybitset) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*0,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*1,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*2,\ydelta) {};
\node[circle, fill=black!25, inner sep=0pt, minimum size=\csize] at (\xoff+\xspace*3,\ydelta) {};
\node[draw=none, fit={(0,0) (\width,\height)}, inner sep=0pt, label={[yshift=-20]center:{\fontsize{280}{0}\selectfont #2}}] {};
\end{tikzpicture}}

\begin{document}
\noindent\knfs{0001}{1}\\
\knfs{0010}{2}\\
\knfs{0011}{3}\\
\knfs{0100}{4}\\
\knfs{0101}{5}\\
\knfs{0110}{6}\\
\knfs{0111}{7}\\
\knfs{1000}{8}\\
\knfs{1001}{9}\\
\knfs{1010}{10}\\
\knfs{1011}{11}\\
\knfs{1100}{12}\\
\knfs{1101}{13}\\
\knfs{1110}{14}
\end{document}

相关内容