我正在为德国的大学开发一款产品,作为论文的一部分。我们应该使用标准方法进行决策。其中一种工具叫做“Auswahlliste”。(我甚至不知道如何翻译。也许是“选择列表”。)它看起来很奇怪,但在德国学术界很受欢迎。但光是想想在tabular
环境中创建它就让我害怕。你有什么建议?你会尝试使用 Tex-measures 来制作它,还是只在 Excel 或任何其他所见即所得软件中制作表格并将其导入为 PDF?有没有合适的工具可以在 Tex-world 中绘制这种奇特的表格?
它看起来是这样的:
此图取自书中Pahl/Beitz 建筑学系,ISBN 978-3-642-29569-0。
为了消除任何疑惑:我不必不惜一切代价让这张桌子看起来像这样。这只是德国工业使用的标准表格设计。我承认这种设计的所有缺陷及其缺乏可读性。我自己乍一看很难理解它。但它仍然是这里广泛接受的标准,我想知道是否可以用 LaTeX 工具绘制它。如果我试图改变它的形状以适合我的口味,我就不会发布这个问题。
答案1
这是我使用 TiKZ 以编程方式创建此类图表的方法的第三次修订。
示例代码
下面是序言和定义:此代码旨在演示我定义的环境/宏的接口。
\begin{document}
\begin{assessmentTable}{%
\newcommand\ItemTitle {L\"osungsvariante (Lv) eintragen:}
\newcommand\ItemHeading {Lv}
\newcommand\AssessmentTitle {Entscheidung}
\newcommand\RemarksTitle {Bemerkungen (Hinweise, Begr\"undungen)}
\AddCriterion {A}{Vertr\"aglichkeit gegeben}
\AddCriterion {B}{Forderungen der Anforderungsliste erf\"ult}
\AddCriterion {C}{Grunds\"atzlich realisiebar}
\AddCriterion {D}{Aufwand zul\"assig}
\AddCriterion {E}{Unmittelbare Sicherheitstechnik gegeben}
\AddCriterion {F}{Im eigenen Bereich bevorzugt}
}%
1 & + & + & + & ? & & & Anzahl er Me{\ss}stellen & ? \\
2 & + & - & & & & & Unterbringung der Masse & - \\
3 & - & & & & & & Radioaktivit\"at & - \\
4 & + & + & + & + & & (+) & (Weiterentwicklung bisheriger L\"osungen) & + \\
5 & + & + & + & + & & & & + \\
6 & - & & & & & & Fl\"ussigkeit nicht Leitend & - \\
7 & + & + & + & + & & & & + \\
8 & + & + & + & + & & & s.\ Lv 7 & +
\end{assessmentTable}
\end{document}
示例输出。
评论。
该表格的构建只需进行简单的宏调用,然后像在 LaTeX 中输入普通表格一样输入表格内容即可。这样可以轻松构建和自定义输出。
代码确实有一些特殊之处。例如,可能需要对长度进行一些调整,以防止表格中的某些文本重叠。此外,我选择编写此环境的一些方法是为了避免神秘的错误:例如,如果在tikzpicture
最后一个\foreach
循环之后环境中出现任何 TiKZ 代码,则定义路径的例程会因\A
不再被定义而产生错误。(我不知道为什么会发生这种情况。)
话虽如此,该代码应该能够针对简单的输入产生合理的结果,并且希望能够适应微小的调整。
下面是生成上述示例文档的代码。
辅助定义
\documentclass[a4paper,10pt]{article}
\usepackage{pbox,tikz}
\usetikzlibrary{matrix,calc,fit,intersections}
\newlength\criterionwidth % width for criterion table columns
\newlength\labelheight % height for labels for assessment criteria
\newlength\labeldepth % depth for labels for assessment criteria
\newlength\itemcolwidth % width for the left-most column
\newlength\criterionlabelskip % vert. skip between legend and first criterion label
\newlength\criterionlabelindent % left indend for criterion labels from their columns
\newlength\assessmentdiagtopstretch % vert.dist. upwards to pull top of the diagonal
\newlength\assessmentdiagbotstretch % vert.dist. downwards to pull bottom of the diagonal
\newlength\remarkswidth % absolute width of remarks column
\newlength\remarksxsep % inner horiz. separation of remarks from column edge
\setlength\criterionwidth {1.5em}
\setlength\labelheight {3ex}
\setlength\labeldepth {1ex}
\setlength\itemcolwidth {3em}
\setlength\criterionlabelskip {2ex}
\setlength\criterionlabelindent {0ex}
\setlength\assessmentdiagtopstretch {5mm}
\setlength\assessmentdiagbotstretch {2mm}
\setlength\remarkswidth {80mm}
\setlength\remarksxsep {1em}
\newcommand\labeltypeface {\itshape} % face for description labels in the table
\newcommand\celltypesize {\footnotesize} % size of evalutation cell contents
\newcommand\remarktypeface {\small} % size of remark cell contents
可以根据喜好改变各种长度,并且可以使用字体来控制表格中文本的外观。
\makeatletter
\newcount\@RemarkCol % Counter for position of the Remarks column
\newtoks\@CriterionNameToks % Token list for labels of the criteria to asses
\@CriterionNameToks{}
\newcommand\AddCriterion[2]{% Macro to define a new criterion column / label
\edef\@tempa{\the\@CriterionNameToks}%
\ifx\empty\@tempa\@CriterionNameToks{{#1}/{#2}}\else
\expandafter\@CriterionNameToks\expandafter{\the\@CriterionNameToks,{#1}/{#2}}
\fi}
该宏旨\AddCriterion
在作为用户界面,用于定义表中的评估标准。我们还定义了一个计数器,用于跟踪备注列的位置,具体取决于要评估的标准数量。
表环境定义
\newenvironment{assessmentTable}[1]{%
\@CriterionNameToks{}%
\@RemarkCol=2\relax
#1%
\begin{tikzpicture}
\expandafter\def\expandafter\@CriterionNames\expandafter{\the\@CriterionNameToks}
\node (CriterionLegend) [inner sep=1em] {\parbox{\paperwidth}{\CriterionLegend}};
\coordinate (Criterion-first-anchor) at ($(CriterionLegend.south west) + (0,-\criterionlabelskip)$);
\def\CriterionAnchor{Criterion-first-anchor}
\foreach \A/\critLabel in \@CriterionNames {
\global\advance\@RemarkCol by 1\relax
\node [anchor=north west, text width=\criterionwidth, minimum height=\labelheight+\labeldepth, inner sep=0pt]
(\A-anchor) at (\CriterionAnchor) {};
\node [anchor=west, text height=\labelheight, text depth=\labeldepth]
(\A-label) at ($(\A-anchor.east) + (\criterionlabelindent,0)$)
{\labeltypeface\critLabel};
\xdef\CriterionAnchor{\A-anchor.south east}%
}
\node [anchor=north west, inner xsep=\remarksxsep, inner ysep=0pt, text height=\labelheight, text depth=\labeldepth,
text width=\remarkswidth-2*\pgfkeysvalueof{/pgf/inner xsep}]
(Remarks-title) at (\CriterionAnchor)
{\labeltypeface\RemarksTitle};
\node [anchor=south west, minimum height=\itemcolwidth,rotate=90]
(ItemTitle) at (Remarks-title.north -| CriterionLegend.west)
{\ItemTitle};
\node [inner sep=0pt, fit=(ItemTitle)(ItemTitle |- CriterionLegend.north)]
(ItemTitle) {};
\def\CriterionAnchor{ItemTitle.west}
\node [anchor=north west, text height=\labelheight, text depth=\labeldepth, inner ysep=0pt]
(ItemHeading) at (ItemTitle.south west) {\ItemHeading};
\foreach \A/\critLabel in \@CriterionNames {%
\node [inner sep=0pt, anchor=south, minimum width=\criterionwidth, text height=\labelheight, text depth=\labeldepth]
(\A-heading) at (ItemHeading.south -| \A-anchor) {\A};
}
\node [anchor=north west, rotate=90, minimum height=\criterionwidth, inner ysep=0pt]
(AssessmentTitle) at (Remarks-title.south east) {\AssessmentTitle};
\node [inner sep=0pt, fit=(AssessmentTitle)] (AssessmentTitle) {};
\node [anchor=north east]
(AssessmentLegend) at (CriterionLegend.north -| AssessmentTitle.east)
{\pbox{\paperwidth}{\AssessmentLegend}};
\def\@GridFinalRow{0}
\matrix [%
anchor=north west, matrix of nodes,%
nodes in empty cells,
inner sep=0pt,
nodes={%
draw=white, inner sep=0pt,
execute at begin node=\celltypesize$,
execute at end node=$\xdef\@GridFinalRow{\pgfmatrixcurrentrow},\iffalse$ Fix some syntax hilighting problems\fi
text height=3ex, text depth=1ex, minimum width=\criterionwidth},
column 1/.style={%
execute at begin node=\expandafter\@gobble\@gobble,
execute at end node=\@gobble,
nodes={minimum width=\itemcolwidth}},
column \the\@RemarkCol/.style={%
execute at begin node=\remarktypeface\expandafter\@gobble\@gobble,
execute at end node=\@gobble,
nodes={%
minimum width=\remarkswidth,
inner xsep=\remarksxsep,
text width=\remarkswidth-2*\pgfkeysvalueof{/pgf/inner xsep}}}
] (Grid) at (ItemHeading.south west)
\bgroup
}{%
\\ \egroup;
\expandafter\ifnum\@GridFinalRow>0
\foreach \row in {1,...,\@GridFinalRow} {%
\draw (Grid-\row-1.south west) -- (Grid-\row-1.south west -| Grid.east);
}
\fi
\draw (ItemTitle.north west) -- (AssessmentLegend.north east)
-- (AssessmentTitle.south east)
-- (ItemHeading.south west) -- cycle;
\draw (Grid.north east) -- (Grid.south east) -- (Grid.south west) -- (Grid.north west);
\draw (CriterionLegend.north west) -- (Criterion-first-anchor);
\draw [name path=AssessmentLegendBoundary]
(AssessmentLegend.north west) -- ($(AssessmentLegend.south west) + (0mm,\assessmentdiagtopstretch)$)
-- ($(AssessmentTitle.north west) + (0mm,-\assessmentdiagbotstretch)$)
-- (AssessmentTitle.south west |- Grid.south);
\path [name path=Remarks-north-boundary] (Remarks-title.north west) -- ($(Remarks-title.north east) + (\paperwidth,0mm)$);
\path [name intersections={of=AssessmentLegendBoundary and Remarks-north-boundary, by={Remarks-north-east-boundary}}];
\draw (Remarks-north-east-boundary) -- (Remarks-title.north west) -- (Remarks-title.north west |- Grid.south);
\foreach \A/\critLabel in \@CriterionNames {%
\path [name path=\A-north-boundary] (\A-anchor.north west) -- ($(\A-anchor.north east) + (\paperwidth,0mm)$);
\path [name intersections={of=AssessmentLegendBoundary and \A-north-boundary, by={\A-north-east-boundary}}];
\draw (\A-north-east-boundary) -- (\A-anchor.north west) -- (\A-anchor.north west |- Grid.south);
}
\end{tikzpicture}%
}
\makeatother
环境清除条件列表并重置备注列的数量,然后允许用户指定命令列表来初始化表格的参数(例如 标准列表、项目标题,ETC。)然后,它使用“图例”(示例中包含标签 、 等描述的大表格单元格)作为基础构建(+)
表格(-)
。
标准的列和标签从图例的左下角开始迭代构建,每个后续标准列都进一步向下和向右构建。(长度
\criterionlabelskip
决定了第一个标签距离图例左下角有多远。)备注列的标签是相对于最后一个条件的位置定义的,并定义表头的底部。
图例单元格和备注列的位置决定了最左边列标题的位置。
图例单元格和备注列的位置也决定了评估列及其图例的位置,原则上它们可能会与某些标准标签重叠。
表格的其余部分作为环境的内容提供,由 TiKZ 节点矩阵组成。标准列的数量决定哪一列是“备注”列,该列具有自己的样式;除了这一列和第一列之外,默认情况下每个单元格都处于数学模式。(第一列和备注列单元格开头的代码用于删除数学模式和调整大小,这是所有其他节点的默认设置。)
在环境的最后,绘制了表格的所有分隔线。
定制
图例的宏和评估的描述可能对于几个表是相同的:它们包含在\pbox
其大小将缩小到其内容大小的 es 中。
\newcommand\CriterionLegend{%
%
L\"osungsvariante {( Lv )} nach \\
\underline{\MakeUppercase{Auswahlkriterien}} beurteilen: \\[2ex]
\begin{tabular}{@{(}c@{)\quad}l}
$+$ & ja
\\
$-$ & nein
\\
? & Informationsmangel
\\
! & Anforderungliste \"uberpr\"ufen
\end{tabular}
%
}
\newcommand\AssessmentLegend{%
%
\begin{tabular}{c@{\quad}l}
\multicolumn{2}{c}{\MakeUppercase{Entscheiden}}
\\
\hline
& L\"osungsvarianten (Lv) \\ & kennzeichnen:
\\[2ex]
($+$) & L\"osung weiter verfolgen
\\
($-$) & L\"osung scheidet aus
\\
(?) & Information beschaffen \\& (L\"osung erneut beurteilen)
\\
(!) & Anforderungliste auf \\& \"Anderung pr\"ufen
\end{tabular}
%
}
所有其他定制大概都应该逐表进行(因此应该作为表参数的一部分进行),或者涉及上面定义的辅助宏和长度。
答案2
\documentclass{article}
\usepackage{array,graphicx}
\setlength\extrarowheight{2pt}
\begin{document}
\noindent
\begin{tabular}{|*{13}{>{\centering\arraybackslash}p{10pt}|}}
\hline
\multicolumn{2}{|c|}{}&
\multicolumn{7}{p{75pt}|}{\raggedright
Stuff\\
\textbf{MORE STUFF}\\[4pt]
(+) yes\\
($-$) no\\
(?) who knows\\
(!) Run!}&
\multicolumn{4}{p{40pt}|}{\raggedright
\textbf{More Stuff}
Stuff\\
goes\\
here}\\
\cline{3-9}
\multicolumn{2}{|c|}{}&\multicolumn{11}{l|}{\ Some kind of title}\\
\cline{4-7}
\multicolumn{2}{|c|}{}&&\multicolumn{10}{l|}{\ Some kind of title 2}\\
\cline{5-8}
\multicolumn{2}{|c|}{}&&&\multicolumn{9}{l|}{\ Another title}\\
\cline{6-9}
\multicolumn{2}{|c|}{}&&&&\multicolumn{8}{l|}{\ Yet Another title}\\
\cline{7-10}
\multicolumn{2}{|c|}{}&&&&&\multicolumn{7}{l|}{\ Yet Another title 2}\\
\cline{8-11}
\multicolumn{2}{|c|}{}&&&&&&\multicolumn{6}{l|}{\ Title \ldots}\\
\cline{9-12}
\multicolumn{2}{|c|}{\rotatebox{90}{\makebox[0pt][l]{Long Column title}}}&&&&&&&\multicolumn{5}{l|}{}\\
\cline{10-12}
\multicolumn{2}{|c|}{Lv}&
A&B&C&D&E&F&G&\multicolumn{3}{l|}{\footnotesize Title (of some sort)}&
\rotatebox{90}{\makebox[0pt][l]{\footnotesize Column title}}\\
\hline
1&1&+&+&+&?& & & &\multicolumn{3}{l}{\footnotesize Something in German}&?\\
2&2&+&$-$& & & & & &\multicolumn{3}{l}{\footnotesize Something else in German}&-\\
\ &\ &\ &\ &\ &\ &\ &\ &\ &\multicolumn{1}{c}{\ }&\multicolumn{3}{c|}{\ }\\
\hline
\end{tabular}
\end{document}
答案3
这tap
可以使用宏来排版此表:
\input tap
\input trans
\beginanchtable
\begintableformat & \center \endtableformat
%\B|+ | | | | | | | | \E|
\diagstroke \trth DOWN {0 0 0 1} a
\B"- " " " " \kern16mm " " " " \E"
\-
\B|: @3 Header | @4 Second header | @2 Last \E|
\-
\B|: | @4 Info | @4 Info 2 \E|
\B|- | @4 \- | " " " \E|
\uranchor8a
\B|: | " @4 Header A " " " \E|
\B|- @2 | @4 \- " " " \E|
\B|: | | " @3 Header B " " " \E|
\B|- @3 | @4 \- " " \E|
\B|: | | | " @2 Header C " " " \E|
\llanchor6a
\B|- @4 | @4 \- | \E|
\B|: Lv | A | B | C | @4 Cos tam | \revolve\hbox{Head rot.} \E|
\=
\B|: 1 | + | + | + | @4 \left{Table position 1} | ? \E|
\-
\B|: 2 | + | -- | | @4 \left{Table position 2} | -- \E|
\-
\B|: 3 | -- | | | @4 \left{Table position 3} | + \E|
\-
\endanchtable
\useanchors
\bye
运行以下命令来获取 PDF:
tex diagonal.tex
dvips diagonal.dvi
ps2pdf diagonal.ps