在純文字中使用 \multispan 為數組提供標題

在純文字中使用 \multispan 為數組提供標題

我正在嘗試修改 WeBWorK 用於生成學生線上數學作業的 pdf 硬拷貝的一些程式碼。我的目標是提高 WeBWorK 的可訪問性。

我目前的任務是為表格添加標題。目前,表格的產生類似於下面 mwe 中的第一個表格。我已經嘗試了很多方法來很好地插入標題,第二個表格展示了我能夠製作的最好的表格。

在此輸入影像描述

問題是我在第三張表中看到的,其中唯一不同的是標題比後續列寬度的總和還要長。在這種情況下,我所擁有的東西並不使標題居中。此外,最好將列保持與前兩個表中一樣分開。

我需要堅持使用純文字。有沒有一刀切的解決方案來解決我的問題?

\batchmode
\documentclass{amsart}


\begin{document}


\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip

%----------------------------

\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\omit\hfil\multispan2{caption}\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip

%----------------------------

\par\medskip\centerline{\kern 1pt\vbox{\halign{#\hfil&&\kern 1em #\hfil\cr
\omit\hfil\multispan2{caption that is very long}\hfil\cr
\hfil \(x\)&\hfil \(y\)\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr
\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}&\hfil \mbox{\parbox[t]{4ex}{\hrulefill}}\cr}}\kern 0pt}\medskip


\end{document}

答案1

我不明白你想透過這種方式獲得什麼利益。我不明白為什麼\halign要以這種方式指定模板。

你的\omit\hfil\multispan錯誤是\hidewidth你正在尋找的。

\documentclass{amsart}


\begin{document}


\centerline{%
  \vbox{
    \halign{%
      #\hfil&&\kern 1em #\hfil\cr
      \hfil \(x\)&\hfil \(y\)\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
    }
  }%
}

\bigskip

\centerline{%
  \vbox{
    \halign{%
      #\hfil&&\kern 1em #\hfil\cr
      \multispan2\hidewidth caption\hidewidth\cr
      \hfil \(x\)&\hfil \(y\)\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
    }
  }%
}

\bigskip

\centerline{%
  \vbox{
    \halign{%
      #\hfil&&\kern 1em #\hfil\cr
      \multispan{2}\hidewidth caption that is very long\hidewidth\cr
      \hfil \(x\)&\hfil \(y\)\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
      \hfil \parbox[t]{4ex}{\hrulefill}&\hfil \parbox[t]{4ex}{\hrulefill}\cr
    }
  }%
}


\end{document}

在此輸入影像描述

相關內容