如何在表格环境中使用多列时正确绘制对角线?

如何在表格环境中使用多列时正确绘制对角线?
\documentclass[a4paper]{article}
\usepackage[cjk]{kotex}
\usepackage{enumerate, float, pgf, tikz, circuitikz, multirow, tabularx, longtable, pdfpages, makecell, hyperref, array, siunitx, diagbox}
%\usepackage[inline]{enumitem}
%\usepackage{showframe}
\setlength{\textheight}{10.75in}
\setlength{\textwidth}{6.5in}
\setlength{\voffset}{-1.5in}
\setlength{\hoffset}{-0.863285in}
\setlength{\marginparwidth}{0in}
\setlength{\marginparpush}{0in}
\hypersetup{pdfborder= 0 0 0}
\title{Example}
\author{Example}
\begin{document}
    \maketitle
        \begin{center}
        \renewcommand{\arraystretch}{1.3}
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{\diagbox{Procedure}{Voltage [\SI{}{\volt}]}} & \thead{1st: 3.606\\ 2nd: 3.02195} & \thead{1st: 5.068\\ 2nd: 5.042} & \thead{1st: 7.064\\ 2nd: 7.0115} & \thead{1st: 9.062\\ 2nd: 9.069}\\
            \hline
            Step (b) & \multirow{2}{*}{Current $I$ [\SI{}{\milli\ampere}]} & 13.4703025775 & 18.9316398954 & 26.3877474785 & 33.8513261113\\
            \cline{1-1}\cline{3-6}
            Step (d) & & 2.54715947404 & 4.24983142279 & 5.90989548213 & 7.64413351315\\
            \hline
        \end{tabular}
    \end{center}
\end{document}

桌子

这是我的代码的表格部分。但是,第一列的对角线的两端似乎没有与单元格的角相交。我发布这个是因为我无法找到我的案例。

答案1

这是一个解决方案,使用\multirowcell代替\multirow。我删除了当前问题中不必要的包。此外,我借此机会简化和改进了代码,特别是S对最后四列使用了列类型:

\documentclass[a4paper]{article}
\usepackage{multirow, tabularx, longtable, makecell, diagbox}
\usepackage{siunitx}
\usepackage{hyperref}
%\usepackage[inline]{enumitem}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}
\setlength{\textheight}{10.75in}
\setlength{\textwidth}{6.5in}
\setlength{\voffset}{-1.5in}
\setlength{\hoffset}{-0.863285in}
\setlength{\marginparwidth}{0in}
\setlength{\marginparpush}{0in}
\hypersetup{pdfborder= 0 0 0}
\title{Example}
\author{Example}

\begin{document}

    \maketitle

        \begin{center}
        \renewcommand{\arraystretch}{1.3}
        \sisetup{table-format=2.11, table-number-alignment=center}
        \begin{tabular}{|c|c|*{4}{S|}}
            \hline
            \multicolumn{2}{|c|}{\diagbox{Procedure}{Voltage [\si{\V}]}} & {\thead{1st: 3.606\\ 2nd: 3.02195}} & {\thead{1st: 5.068\\ 2nd: 5.042}} & {\thead{1st: 7.064\\ 2nd: 7.0115}} & {\thead{1st: 9.062\\ 2nd: 9.069}}\\
            \hline
            Step (b) & \multirowcell{2}{Current $I$ \\[-0.5ex][\si{\mA}]} & 13.4703025775 & 18.9316398954 & 26.3877474785 & 33.8513261113\\
            \cline{1-1}\cline{3-6}
            Step (d) & & 2.54715947404 & 4.24983142279 & 5.90989548213 & 7.64413351315\\
            \hline
        \end{tabular}
    \end{center}

\end{document} 

在此处输入图片描述

答案2

借助可选width参数,\diagbox您可以实现以下目标:

在此处输入图片描述

\documentclass[a4paper]{article}
\usepackage[cjk]{kotex}
\usepackage{enumerate, float, pgf, tikz, circuitikz, multirow, tabularx, longtable, pdfpages, makecell, hyperref, array, siunitx, diagbox}
\usepackage{calc}


\setlength{\textheight}{10.75in}
\setlength{\textwidth}{6.5in}
\setlength{\voffset}{-1.5in}
\setlength{\hoffset}{-0.863285in}
\setlength{\marginparwidth}{0in}
\setlength{\marginparpush}{0in}
\hypersetup{pdfborder= 0 0 0}

\begin{document}

        \begin{center}
        \renewcommand{\arraystretch}{1.3}
        \begin{tabular}{|c|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{\diagbox[width=\widthof{Step (b)}+\widthof{Current $I$ [\SI{}{\milli\ampere}]}+4\tabcolsep+\arrayrulewidth\relax]{Procedure}{Voltage [\SI{}{\volt}]}} & \thead{1st: 3.606\\ 2nd: 3.02195} & \thead{1st: 5.068\\ 2nd: 5.042} & \thead{1st: 7.064\\ 2nd: 7.0115} & \thead{1st: 9.062\\ 2nd: 9.069}\\
            \hline
            Step (b) & \multirow{2}{*}{Current $I$ [\SI{}{\milli\ampere}]} & 13.4703025775 & 18.9316398954 & 26.3877474785 & 33.8513261113\\
            \cline{1-1}\cline{3-6}
            Step (d) & & 2.54715947404 & 4.24983142279 & 5.90989548213 & 7.64413351315\\
            \hline
        \end{tabular}
    \end{center}
\end{document}

相关内容