So codieren Sie diese Tabelle

So codieren Sie diese Tabelle

Ich habe versucht, diese Tabelle zu erstellen, habe aber ein Problem mit meinem Code. Wie kann ich meinen Code ändern, um die gewünschte Ausgabe zu erhalten?

\documentclass[11pt,a5paper]{article}
\usepackage{multirow}
\begin{document}
 \begin{tabular}{ |l|l|l| }
\hline
\multicolumn{3}{ |c| }{x=0.5&x=0.6 & x=0.7} \\
 \hline
 MD &RM& MD\\ \hline
 3& 8 & 7 \\
 4 & 10& 8\\
 5& 3& 9 \\
 \\ \hline

 \hline
\end{tabular}
\end{document}

Bildbeschreibung hier eingeben

Antwort1

Sie verwenden Folgendes falsch \multicolumn:

\documentclass[11pt,a5paper]{article}
\begin{document}
\begin{tabular}{ |*{6}{c|} }
\hline
\multicolumn{2}{ |c| }{$x=0.5$} &
\multicolumn{2}{ c| }{$x=0.6$} &
\multicolumn{2}{ c| }{$x=0.7$} \\
\hline
MD & RM& MD & RM & MD & RM \\
\hline
3 &  8 & 7 & 11 & 0 & 1 \\
4 & 10 & 8 & 12 & 4 & 2 \\
5 &  3 & 9 &  1 & 3 & 0 \\
\hline
\multicolumn{2}{ |c| }{$y=70$} &
\multicolumn{2}{ c| }{$z=50$} &
\multicolumn{2}{ c| }{$xy=10$} \\
\hline
\end{tabular}
\end{document}

Bildbeschreibung hier eingeben

Beachten Sie, dass dies multirownicht erforderlich ist (es ist fast nie erforderlich).

Eine andere Realisierung mitbooktabs

\documentclass[11pt,a5paper]{article}

\usepackage{booktabs}

\begin{document}
\begin{tabular}{ *{6}{c} }
\toprule
\multicolumn{2}{ c }{$x=0.5$} &
\multicolumn{2}{ c }{$x=0.6$} &
\multicolumn{2}{ c }{$x=0.7$} \\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
MD & RM& MD & RM & MD & RM \\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
3& 8 & 7 & 11 & 0 & 1\\
4 & 10& 8 & 12 & 4 & 2\\
5& 3& 9 & 1 & 3 & 0\\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
\multicolumn{2}{ c }{$y=70$} &
\multicolumn{2}{ c }{$z=50$} &
\multicolumn{2}{ c }{$xy=10$} \\
\bottomrule
\end{tabular}
\end{document}

Bildbeschreibung hier eingeben

Eine weitere Verfeinerung siunitxermöglicht eine bessere Platzierung der Zahlen:

\documentclass[11pt,a5paper]{article}

\usepackage{booktabs,siunitx}

\begin{document}
\begin{tabular}{ *{6}{S[table-format=2.0]} } % two digits for the integral part, no decimals
\toprule
\multicolumn{2}{ c }{$x=0.5$} &
\multicolumn{2}{ c }{$x=0.6$} &
\multicolumn{2}{ c }{$x=0.7$} \\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
{MD} & {RM} & {MD} & {RM} & {MD} & {RM} \\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
3& 8 & 7 & 11 & 0 & 1\\
4 & 10& 8 & 12 & 4 & 2\\
5& 3& 9 & 1 & 3 & 0\\
\cmidrule(lr){1-2}
\cmidrule(lr){3-4}
\cmidrule(lr){5-6}
\multicolumn{2}{ c }{$y=70$} &
\multicolumn{2}{ c }{$z=50$} &
\multicolumn{2}{ c }{$xy=10$} \\
\bottomrule
\end{tabular}
\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen