在下面的,
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{xcolor,colortbl}
%\usepackage{wasysym}
\usepackage{array,ltablex,graphicx,multirow,tabularx}
\usepackage{siunitx}
\usepackage{fancyhdr}
\usepackage{pdflscape}
\usepackage[left=2.00cm, right=3.00cm, top=0.500cm, bottom=2.50cm, includefoot]{geometry}
\pagestyle{empty}
\renewcommand{\arraystretch}{2}
\definecolor{myblue}{HTML}{BDD6EE}
\author{Andrea Croci}
\begin{document}
\begin{landscape}
\thispagestyle{empty}
\begin{tabularx}{\columnwidth}{|>{\raggedright\arraybackslash}p{2cm}|X|X|X|X|X|X|}
\hline
\multicolumn{7}{|c|}{{\Large \textbf{Messwertetabelle}} \newline Trage die Zeiten ein}\\
\hline
Masse & \multicolumn{2}{|X|}{Masse des Wagens \underline{\phantom{Masse des Wagens}} g} & \multicolumn{2}{|X|}{Masse des Wagens \underline{\phantom{Masse des Wagens}} g} & \multicolumn{2}{|X|}{Masse des Wagens \underline{\phantom{Masse des Wagens}} g}\\
\hline
\end{tabularx}
\end{landscape}
\end{document}
\newline
中的被\multicolumn
忽略了,我尝试了几种不同的解决方案,但都没有奏效。我还希望下划线在单独的一行中。我尝试使用p{}
(或类似的)列类型,\multicolumn
但随后我必须手动输入宽度,我希望它像在X
列中一样自动计算。
如何在单元格中断线\multicolumn
?
答案1
考虑到对您的问题的评论,我建议您采用以下解决方案:
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[table]{xcolor}
\definecolor{myblue}{HTML}{BDD6EE}
%\usepackage{wasysym}
\usepackage{graphicx}
\usepackage{makecell, multirow,tabularx}
\usepackage{siunitx}
\usepackage{fancyhdr}
\usepackage{pdflscape}
\usepackage[hmargin={2cm, 3cm},
vmargin={0.5cm,2.5cm},
includefoot]{geometry}
\pagestyle{empty}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{|c|}{#2}}
\author{Andrea Croci}
\begin{document}
\begin{landscape}
\centering
\renewcommand\theadfont{\Large\bfseries}
\setcellgapes{5pt}
\makegapedcells
\begin{tabularx}{\linewidth}{|l|X|X|X|}
\hline
\mcc[4]{\thead{Messwertetabelle\\
\normalfont
Trage die Zeiten ein}} \\
\hline
Masse & Masse des Wagens \hrulefill\ g
& Masse des Wagens \hrulefill\ g
& Masse des Wagens \hrulefill\ g\\
\hline
\end{tabularx}
\end{landscape}
\end{document}
如您所见,\underline
我们使用了而不是\hrulefill
来获得额外的垂直空间,这里使用了宏makegapedcells
(在makecell
包中定义)。
附录: 从OP评论中可以理解,他的表格所需的格式是:
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[table]{xcolor}
\definecolor{myblue}{HTML}{BDD6EE}
%\usepackage{wasysym}
\usepackage{graphicx}
\usepackage{makecell, multirow,tabularx}
\usepackage{siunitx}
\usepackage{fancyhdr}
\usepackage{pdflscape}
\usepackage[hmargin={2cm, 3cm},
vmargin={0.5cm,2.5cm},
includefoot]{geometry}
\pagestyle{empty}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{|c|}{#2}}
\author{Andrea Croci}
\begin{document}
\begin{landscape}
\centering
\renewcommand\theadfont{\bfseries}
\setcellgapes{5pt}
\makegapedcells
\begin{tabularx}{\linewidth}{|l|X|X|X|}
\hline
\mcc[4]{\thead{\Large Messwertetabelle\\
\normalfont
Trage die Zeiten ein}} \\
\hline
Masse & Masse des Wagens \hrulefill\ g
& Masse des Wagens \hrulefill\ g
& Masse des Wagens \hrulefill\ g\\
\hline
\end{tabularx}
\end{landscape}
\end{document}