表格居中

表格居中

如何使第一列与其他列一样居中?

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\title{Table}
\author{Armin Weber}
\date{April 2024}

\begin{document}



\maketitle

\section{Introduction}


\newpage

\begin{table}[]
\begin{tabular}{|M{2cm}|M{8cm}|M{2cm}|M{2cm}|}

\hline
\rule{0pt}{25pt} {\textbf{Aufgabe}} & \textbf{Erklärung} & \textbf{Punkte} & \textbf{Erreicht} \\ 
\hline
\rule{0pt}{25pt}               1                        &       5             &                 &   \\ 
\hline
\rule{0pt}{25pt}                     2                  &         6           &                 &   \\
\hline
\rule{0pt}{25pt}           3                            &          7          &                 &   \\
\hline  
\rule{0pt}{25pt}               4                        &         8           &                 &   \\
\hline
\rule{0pt}{25pt}                                       &                    &                 &   \\ 
\hline
\rule{0pt}{25pt}                                       &                    &                 &   \\
\hline 
\rule{0pt}{25pt}                                       &                    &                 &   \\
\hline
\rule{0pt}{25pt}                                       &                    &                 &   \\
\hline
\rule{0pt}{25pt}                                       &                    &                 &  
                                       \\ 
\hline
\end{tabular}
\end{table}

\end{document}

这就是结果

答案1

我会把 struts 构建到M说明符中

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{array}
\newcommand\strutwd{0pt}
\newcolumntype{M}[1]{>{\rule{\strutwd}{25pt}\centering\arraybackslash}m{#1}<{\rule[-10pt]{\strutwd}{25pt}}   }
\title{Table}
\author{Armin Weber}
\date{April 2024}

\begin{document}

\maketitle

\section{Introduction}


\newpage

\begin{table}
\begin{tabular}{|M{2cm}|M{8cm}|M{2cm}|M{2cm}|}

\hline
  {\textbf{Aufgabe}}   & \textbf{Erklärung} & \textbf{Punkte} & \textbf{Erreicht} \\ 
\hline
               1       & 5                  &                 &                   \\ 
\hline
                     2 & 6                  &                 &                   \\
\hline
           3           & 7                  &                 &                   \\
\hline  
               4       & 8                  &                 &                   \\
\hline
                       &                    &                 &                   \\ 
\hline
                       &                    &                 &                   \\
\hline 
                       &                    &                 &                   \\
\hline
                       &                    &                 &                   \\
\hline
                       &                    &                 & 
                                                                                  \\ 
\hline
\end{tabular}
\end{table}

\end{document}

相关内容