TabularX 调整

TabularX 调整

我正在尝试制作一个表格来TabularX帮助孩子们理解分数和小数的转换。

问题:

(1)如何修复右下角合并单元格的垂直对齐方式?

(2)有没有简单的方法可以让五列均匀分布?

(3)我\paddingtop按照我之前的帖子有没有更简单的方法将内容与水平规则分开?理想情况下,垂直规则不会延伸得太远,进入合并单元格。

\documentclass{article}

\usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=2cm]{geometry}
\usepackage{lscape}
\usepackage{tikz}
\usepackage{tabularx}

 % Will be my standard column with all contents centered horizontally and vertically.
 \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

 % redefines the final X column as vertically centered.
 \renewcommand*{\tabularxcolumn}[1]{m{#1}}

 % Not sure what this does
 \usepackage{cellspace}
 \setlength\cellspacetoplimit{20pt}
 \setlength\cellspacebottomlimit{4pt}

 % Not sure what this does
 \addparagraphcolumntypes{X}

 % The insanely complex stuff for creating the paddingtop part. 
   I would love a simpler way of doing this.
 \makeatletter
 \newsavebox\saved@arstrutbox
 \newcommand*{\setarstrut}[1]{%
  \noalign{%
    \begingroup
      \global\setbox\saved@arstrutbox\copy\@arstrutbox
      \global\setbox\@arstrutbox\hbox{%
        \vrule \@height #1
               \@depth  0cm
               \@width\z@
      }%
    \endgroup
  }%
 }
 \newcommand*{\restorearstrut}{%
  \noalign{%
    \global\setbox\@arstrutbox\copy\saved@arstrutbox
  }%
 }
 \makeatother

 % New command to add an extra custom padding at the top of a row.
 % Basically, it adds an empty row with the height value defined in the command.

 % \paddingtop{height}{content, i.e. ampersands}

 \newcommand{\paddingtop}[2]{\setarstrut{#1} #2 \\ \restorearstrut}

% MACRO for basic number line with whole numbers underneath and fractional tick marks. Must be *inside* a tikz environment
\newcommand{\NL}[2] %{xmax}{denom}
{
 \draw (0,0)--(#1,0);
 \pgfmathparse{#1*#2}
 \foreach \x in {0,...,\pgfmathresult}
  \draw (\x/#2,-0.2)--(\x/#2,0.2);
 \foreach \x in {0,...,#1}
  \node[anchor=mid] at (\x,-0.65) {\x};
}


\newcommand{\decimaltable}
{

\begin{tabularx}{23cm}{*4{|C{4.2cm}}|X|} \hline

\paddingtop{0.2cm}{&&&&}

Decimal(s) \vspace{2.5cm} & Mixed Number(s) \vspace{2.5cm} &  Hundredths Only \vspace{2.5cm} & Tenths \& Hundredths \vspace{2.5cm} & Other Denominators \vspace{2.5cm}\\ \hline

\paddingtop{0.2cm}{&&&&}
Price \vspace{2.5cm} & As few L, D and P as possible. \vspace{2.5cm} & \multicolumn{3}{c|}{Other Coin Denominations}\\ \hline

\end{tabularx}

}

\begin{document}

\begin{landscape}
\decimaltable
\end{landscape}

\end{document}

答案1

tabularx实际上是错误的工具,因为列宽是预先知道的。我一般简化标记,但似乎制作了所需的表格。

在此处输入图片描述

\documentclass{article}

\usepackage[left=1.5cm,right=1.5cm,top=2cm,bottom=2cm]{geometry}
\usepackage{lscape,array}

\newcommand{\decimaltable}
{{\par
\setlength\extrarowheight{10pt}%
\begin{tabular}{|*5{>{\centering\arraybackslash}p{4.2cm}|}} \hline
Decimal(s) & 
Mixed Number(s) &  
Hundredths Only  & 
Tenths \& Hundredths & 
Other Denominators \\[2cm] \hline
Price & 
As few L, D and P as possible.& 
\multicolumn{3}{c|}{Other Coin Denominations}\\[2cm]\hline
\end{tabular}\par
}}

\begin{document}

\begin{landscape}
\decimaltable
\end{landscape}

\end{document}

相关内容