我在为我的训练计划重建一个复杂的表格时遇到了问题。书中的一个填充大循环攀岩训练好像:
我尝试使用 tabularx 和子表来显示细网格线,但它崩溃了。这是一个代码示例(没有子表):
\documentclass[11pt,a4paper,landscape]{scrartcl}
\usepackage[left=1.5cm,right=1cm,top=2cm,bottom=1cm]{geometry}
\usepackage{tabularx}
\usepackage{array,booktabs,pgffor}
\newcommand{\numarr}[1]{%
\foreach \n in {1,...,#1}{\footnotesize\ \n}
}
\newcommand{\emarr}[1]{%
\foreach \n in {1,...,#1}{\footnotesize\ \phantom{x}}
}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{1.3}
\begin{document}
\begin{tabularx}{.4\textwidth}{@{}r|Y|Y|Y@{}}
Year & \multicolumn{3}{c}{Header} \\
\hline
\phantom{x2022x}%
& \multicolumn{3}{c}{}%
\\[1cm]
\hline
month & Jan & Feb & Mär
\\
\hline
weak%
&\numarr{5}%
&\numarr{4}%
&\numarr{4}%
\\
\hline
Fokus
&grid&grid&grid
\\[3em]
\hline
&grid&grid&grid
\\[3em]
\hline
&&&
\\[8em]
\hline
\end{tabularx}
\end{document}
如果有人能提供提示或类似的例子我会非常高兴。
提前感谢!Tommy
答案1
您也可以尝试使用bytefield
包,当您需要\multicolumns
在表格中输入大量内容时,这个包有时会更容易使用。由于所有网格线的大小都相同,因此我添加了一些额外的间距
\documentclass{article}
\usepackage[margin=.75in]{geometry}
\usepackage{bytefield}
\usepackage{rotating}
\begin{document}
\thispagestyle{empty}
\begin{sidewaystable}
\centering
\begin{bytefield}[bitwidth=1em]{67}
\bitbox{15}{\raggedright\ Name/Year}& \bitbox{52}{Training Objectives and Seasonal Climbing Goals}\\
\bytefieldsetup{bitheight=12ex}%
\bitbox{15}{}&\bitboxes{13}{{}{}{}{}}\\
\bytefieldsetup{bitheight=3ex}%
\bitbox{15}{\raggedright\ Month} & \bitbox{5}{Jan} & \bitboxes{4}{{Feb}{Mar}} & \bitbox{5}{Apr} & \bitboxes{4}{{Jun}{May}} & \bitbox{5}{Jul} & \bitboxes{4}{{Aug}{Sep}} & \bitbox{5}{Oct} & \bitboxes{4}{{Nov}{Dec}}\\
\bitbox{15}{\raggedright\ Week} & \bitboxes{1}{{\tiny1} {\tiny2} {\tiny3} {\tiny4} {\tiny5} {\tiny6} {\tiny7} {\tiny8} {\tiny9} {\tiny10} {\tiny11} {\tiny12} {\tiny13} {\tiny14} {\tiny15} {\tiny16} {\tiny17} {\tiny18} {\tiny19} {\tiny20} {\tiny21} {\tiny22} {\tiny23} {\tiny24} {\tiny25} {\tiny26} {\tiny27} {\tiny28} {\tiny29} {\tiny30} {\tiny31} {\tiny32} {\tiny33} {\tiny34} {\tiny35} {\tiny36} {\tiny37} {\tiny38} {\tiny39} {\tiny40} {\tiny41} {\tiny42} {\tiny43} {\tiny44} {\tiny45} {\tiny46} {\tiny47} {\tiny48} {\tiny49} {\tiny50} {\tiny51} {\tiny52}}\\[1ex]
\bitbox[lt]{2}{}&\bitbox{13}{\raggedright\ Stamina/skill}&\bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{2}{}&\bitbox{13}{\raggedright\ Max. Strength and power}&\bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{2}{\rotatebox[origin=tl]{90}{\ \ \ Training focus}}&\bitbox{13}{\raggedright\ Anaerobic Performance}&\bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[lb]{2}{}&\bitbox{13}{\raggedright\ Rest}&\bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\[1ex]
\bitbox[lt]{14}{} & \bitbox[tr]{1}{\tiny7} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{14}{} & \bitbox[]{1}{\tiny6} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{14}{} & \bitbox[r]{1}{\tiny5} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{14}{\raggedright\ Total number of days per\\\ week of finger training or\\\ climbing} & \bitbox[]{1}{\tiny4} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{14}{} & \bitbox[]{1}{\tiny3} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[l]{14}{} & \bitbox[]{1}{\tiny2} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bitbox[lb]{14}{} & \bitbox[b]{1}{\tiny1} & \bitboxes{1}{{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}}\\
\bytefieldsetup{bitheight=18ex}%
\bitbox{15}{\raggedright\ Benchmark achievements\\\ and notes} & \bitbox{5}{} & \bitboxes{4}{{}{}} & \bitbox{5}{} & \bitboxes{4}{{}{}} & \bitbox{5}{} & \bitboxes{4}{{}{}} & \bitbox{5}{} & \bitboxes{4}{{}{}}\\
\end{bytefield}
\end{sidewaystable}
\end{document}
答案2
获得通常的做法来自 John Kormylo,我切换到 tabu 包并使用了https://tex.stackexchange.com/a/489775/238225生成一个按日历周编号的(空)循环。这是我的方法:
\documentclass{article}
\usepackage[margin=.75in]{geometry}
\usepackage{rotating}
\usepackage[ngerman]{babel} % English language hyphenation
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Use 8-bit encoding
\usepackage{tabu}
\usepackage{multirow}
\usepackage{array,booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\mcfront}[1]{\multicolumn{3}{c!{\vrule width 1.2pt}}{#1}}
\newcommand{\mcquart}{\multicolumn{13}{c!{\vrule width 1.2pt}}{}}
\newcommand{\mcmonth}[1]{\multicolumn{4}{c|}{#1}}
\newcommand{\mcrmonth}[1]{\multicolumn{4}{c!{\vrule width 1.2pt}}{#1}}
\newcommand{\mclmonth}[1]{\multicolumn{5}{c|}{#1}}
%loop to generate cells
\newcounter{col}
\makeatletter
\newcommand\colloop@add[2]
{%
\expandafter\g@addto@macro\expandafter\colloop@\expandafter
{\colloop@@{#1}}%
\ifnum#2>\value{col}
\g@addto@macro\colloop@{&}%
\fi
}
\newcommand\colloop[2]
{%
{%
\setcounter{col}{0}%
\gdef\colloop@{}%
\gdef\colloop@@##1{#2}%
\loop\ifnum#1>\value{col}
\stepcounter{col}%
\expandafter\colloop@add\expandafter{\the\value{col}}{#1}%
\repeat
}%
\colloop@
}
\makeatletter
\begin{document}
\setlength{\tabcolsep}{1pt}
\begin{sidewaystable}
\centering
\begin{tabu} to .9\textwidth {llr !{\vrule width 1.2pt}Y *{12}{|Y} !{\vrule width 1.2pt}Y *{12}{|Y} !{\vrule width 1.2pt}Y *{12}{|Y} !{\vrule width 1.2pt}Y *{12}{|Y} !{\vrule width 1.2pt}}%
\tabucline[1.2pt]-
\rowfont[c]\bfseries
\multicolumn{3}{c!{\vrule width 1.2pt}}{Jahr}& \multicolumn{52}{c!{\vrule width 1.2pt}}{Trainings- und Kletterziele} \\
\tabucline[1.2pt]-
\mcfront{} & \mcquart & \mcquart & \mcquart & \mcquart
\\[2cm]
\tabucline[1.2pt]-
\multicolumn{3}{r!{\vrule width 1.2pt}}{Monat\phantom{x}}
& \mclmonth{Jan}
& \mcmonth{Feb}
& \mcrmonth{Mär}
& \mclmonth{Apr}
& \mcmonth{Mai}
& \mcrmonth{Jun}
& \mclmonth{Jul}
& \mcmonth{Aug}
& \mcrmonth{Sep}
& \mclmonth{Okt}
& \mcmonth{Nov}
& \mcrmonth{Dez}
\\
\tabucline[1.4pt]-
\multicolumn{3}{r!{\vrule width 1.2pt}}{Woche\phantom{x}}
&
\colloop{52}{\footnotesize #1}
\\
\tabucline[1.4pt]-
\parbox[t]{4mm}{\multirow{6}{*}{\rotatebox{90}{Fokus}}}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Technik} &\colloop{52}{}\\\tabucline{2-}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Max-/Schnellkraft} &\colloop{52}{}\\\tabucline{2-}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Kraftausdauer} &\colloop{52}{}\\\tabucline{2-}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Anaerobe Ausdauer} &\colloop{52}{}\\\tabucline{2-}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Aerobe Ausdauer} &\colloop{52}{}\\\tabucline{2-}
& \multicolumn{2}{|c!{\vrule width 1.2pt}}{Ruhetag} &\colloop{52}{}
\\
\tabucline[1.4pt]-
& \parbox[t]{4mm}{\multirow{8}{*}{\begin{minipage}{8em}\centering Anzahl an Kletter- und Trainingstagen pro Woche\end{minipage}}}
& \parbox[t]{4mm}{\multirow{8}{*}{\begin{minipage}{1em}\centering\vspace{.3em}7\vspace{.3pt}
6\vspace{0.3pt}
5\vspace{0.3pt}
4\vspace{0.3pt}
3\vspace{0.3pt}
2\vspace{0.3pt}
1\vspace{0.3pt}
\end{minipage}}}
&\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}\\\tabucline{4-}
&& &\colloop{52}{}
\\
\tabucline[1.4pt]-
\multicolumn{3}{r!{\vrule width 1.2pt}}{Gewicht\phantom{x}} &\colloop{52}{}
\\
\tabucline[1.4pt]-
\multicolumn{3}{r!{\vrule width 1.2pt}}{\begin{minipage}{8em}\centering \vspace{2.25cm}Erfolge und Kommentare\vspace{2.25cm}\end{minipage}}
& \mclmonth{}
& \mcmonth{}
& \mcrmonth{}
& \mclmonth{}
& \mcmonth{}
& \mcrmonth{}
& \mclmonth{}
& \mcmonth{}
& \mcrmonth{}
& \mclmonth{}
& \mcmonth{}
& \mcrmonth{}
\\
\tabucline[1.4pt]-
\end{tabu}
\end{sidewaystable}
\end{document}
我试图避免使用 tabu 包,但我无法用 重建它tabularx
。