长度不符合规定

长度不符合规定

作为库存工具的一部分,我想使用以下代码通过 PDFLaTex 打印零件盒的内容。

\documentclass[8pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc} %% instead ansinew or latin1
\usepackage[T1]{fontenc}
\usepackage[right]{eurosym}
\usepackage[lmargin=0cm,rmargin=0cm,tmargin=0.5cm,paperwidth=116mm,paperheight=247mm]{geometry}
\usepackage{textpos}
\usepackage{textgreek}
\pagestyle{empty}
\setlength{\columnseprule}{1pt}
\newlength{\traywidth} \setlength{\traywidth}{50mm}
\newlength{\trayheight} \setlength{\trayheight}{30mm}
\begin{document}
\ttfamily
\small
\begin{textblock}{50}(0,-0.2) Box res-1: {\bf Resistor} (Boxtype x: Acryl, klein, alt) \end{textblock}
\begin{tabular}{|l|l|}
\hline
\parbox[b][\trayheight][t]{\traywidth}{
\setlength{\tabcolsep}{2pt}
\begin{tabular}{rll}
\fbox{{\scriptsize b1}}&{\scriptsize Resistor}&\\
     1&5,0 Ω&\\
     4&5,1 Ω&\\
     1&5,6 Ω&\\
\end{tabular}
}&
\parbox[b][\trayheight][t]{\traywidth}{
\setlength{\tabcolsep}{2pt}
\begin{tabular}{rll}
\fbox{{\scriptsize b2}}&{\scriptsize Resistor}&\\
     8&10 Ω&\\
     2&12 Ω&\\
     3&15 Ω&\\
\end{tabular}
}\\
\hline
\end{tabular}
\end{document}

我的问题:

打印纸上的定义\traywidth宽度正好是 60 毫米,\trayheight纸张上的长度是 34 毫米,都不是我所说的长度。

请告诉我我做错了什么。提前谢谢您,Rick。

答案1

您忘记了 parbox 之间的 tabcolsep 以及表格线的深度。

\documentclass[8pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc} %% not needed in a current tex system
\usepackage[T1]{fontenc}
\usepackage[right]{eurosym}
\usepackage[lmargin=0cm,rmargin=0cm,tmargin=0.5cm,paperwidth=116mm,paperheight=247mm]{geometry}
\usepackage{textpos}
\usepackage{textgreek}
\pagestyle{empty}
\setlength{\columnseprule}{1pt}
\newlength{\traywidth} \setlength{\traywidth}{\dimexpr50mm-2\tabcolsep}
\normalsize
\newlength{\trayheight} \setlength{\trayheight}{\dimexpr30mm-\dp\strutbox}
\usepackage{tikz}
\begin{document}
\ttfamily
\small
\begin{textblock}{50}(0,-0.2) Box res-1: {\bf Resistor} (Boxtype x: Acryl, klein, alt) \end{textblock}
\begin{tabular}{|l|l|}
\hline
\tikz[overlay]\draw[green](-\tabcolsep,15mm)--++(50mm,0mm);%
\tikz[overlay]\draw[red](0.5,-\dp\strutbox)--++(0,30mm);\parbox[b][\trayheight][t]{\traywidth}{%
\setlength{\tabcolsep}{2pt}%
\begin{tabular}{rll}
\fbox{{\scriptsize b1}}&{\scriptsize Resistor}&\\
     1&5,0 Ω&\\
     4&5,1 Ω&\\
     1&5,6 Ω&\\
\end{tabular}
}&
\parbox[b][\trayheight][t]{\traywidth}{%
\setlength{\tabcolsep}{2pt}%
\begin{tabular}{rll}
\fbox{{\scriptsize b2}}&{\scriptsize Resistor}&\\
     8&10 Ω&\\
     2&12 Ω&\\
     3&15 Ω&\\
\end{tabular}
}\\
\hline
\end{tabular}
\end{document}

相关内容