具有相同列宽的表格

具有相同列宽的表格

这是一张显示长除法练习的表格。网格需要看起来像一本笔记本。我对表格中的列宽有一个问题,根据显示的字符,列宽会发生变化。当显示余数“R”时,列宽会变宽,而显示“)”的列宽会变窄

我尝试了一些方法来解决这个问题,但它们都与软件包或代码不兼容。

请问,我需要一个关于如何解决这个问题的线索。

长除法网格

\documentclass[twoside, 12pt]{article}
\usepackage[hmargin=0.75in, vmargin=0.5in, includeheadfoot, headheight=10mm, headsep=4mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage[table]{xcolor}
\usepackage{pslatex}
\usepackage{booktabs}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.0pt}

\definecolor{bluegray}{rgb}{0.90, 0.90, 1.0}
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}
\def\Hline{\arrayrulecolor{bluegray}\specialrule{1pt}{0pt}{0pt}}
\arrayrulecolor{bluegray}

\begin{document}
\begin{tabular}{ccc}
\begin{minipage}[c][4.0in][t]{2.33333333333in}
\setlength{\tabcolsep}{2pt}

\begin{tabular}{
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}}
\Hline
\textcolor{red}{ } & \textcolor{red}{ } &  & \textcolor{red}{ } & \textcolor{red}{ } & \textcolor{red}{9} & \textcolor{red}{2}\\ \Hline
\arrayrulecolor{black}
\cline{3-7}
\arrayrulecolor{bluegray}
9 & 7 & ) & 8 & 9 & 4 & 6 \\ \Hline
  &   & - & 0 &   &   &   \\ \Hline
\arrayrulecolor{black}
\cline{4-4}
\arrayrulecolor{bluegray}
  &   &   & 8 & 9 &   &   \\ \Hline
  &   &   & - & 0 &   &   \\ \Hline
\arrayrulecolor{black}
\cline{5-5}
\arrayrulecolor{bluegray}
  &   &   & 8 & 9 & 4 &   \\ \Hline
  &   & - & 8 & 7 & 3 &   \\ \Hline
\arrayrulecolor{black}
\cline{4-6}
\arrayrulecolor{bluegray}
  &   &   &   & 2 & 1 & 6 \\ \Hline
  &   &   & - & 1 & 9 & 4 \\ \Hline
\arrayrulecolor{black}
\cline{5-7}
\arrayrulecolor{bluegray}
  &   &   &   & R & 2 & 2 \\ \Hline
\end{tabular}
\end{minipage}
\end{tabular}
\end{document}

答案1

我建议你

  • \hphantom{0}在第一行的第三个单元格中插入指令,然后

  • mathtools在序言中加载包,并将R最后一行的 替换为$\mathclap{\text{R}}$

可选:用 替换四个-(减号)符号$\mathclap{-}$

在此处输入图片描述

\documentclass[twoside, 12pt]{article}
\usepackage[hmargin=0.75in, vmargin=0.5in, includeheadfoot, headheight=10mm, headsep=4mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage[table]{xcolor}
\usepackage{pslatex}
\usepackage{booktabs}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.0pt}

\definecolor{bluegray}{rgb}{0.90, 0.90, 1.0}
\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}
\def\Hline{\arrayrulecolor{bluegray}\specialrule{1pt}{0pt}{0pt}}
\arrayrulecolor{bluegray}

\usepackage{mathtools}

\begin{document}
\begin{tabular}{ccc}
\begin{minipage}[c][4.0in][t]{2.33333333333in}
\setlength{\tabcolsep}{2pt}

\begin{tabular}{
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}c
!{\color{bluegray}\VRule[1pt]}}
\Hline
 &  & \hphantom{0} &  & & \textcolor{red}{9} & \textcolor{red}{2}\\ \Hline
\arrayrulecolor{black}
\cline{3-7}
\arrayrulecolor{bluegray}
9 & 7 & ) & 8 & 9 & 4 & 6 \\ \Hline
  &   & $\mathclap{-}$ & 0 &   &   &   \\ \Hline
\arrayrulecolor{black}
\cline{4-4}
\arrayrulecolor{bluegray}
  &   &   & 8 & 9 &   &   \\ \Hline
  &   &   & $\mathclap{-}$ & 0 &   &   \\ \Hline
\arrayrulecolor{black}
\cline{5-5}
\arrayrulecolor{bluegray}
  &   &   & 8 & 9 & 4 &   \\ \Hline
  &   & $\mathclap{-}$ & 8 & 7 & 3 &   \\ \Hline
\arrayrulecolor{black}
\cline{4-6}
\arrayrulecolor{bluegray}
  &   &   &   & 2 & 1 & 6 \\ \Hline
  &   &   & $\mathclap{-}$ & 1 & 9 & 4 \\ \Hline
\arrayrulecolor{black}
\cline{5-7}
\arrayrulecolor{bluegray}
  &   &   &   & $\mathclap{\text{R}}$ & 2 & 2 \\ \Hline
\end{tabular}
\end{minipage}
\end{tabular}
\end{document}

相关内容