我正在使用 apa6 类。我的文档有一些 实例threeparttable
。我无法使用 来\columnwidth
定义表格以匹配我的两列文章的列宽。
我读过了这里APA 类别重新定义,\tabular
这似乎是造成此问题的原因。
不幸的是我无法将答案转移到我的情况中threeparttable
。
我正在使用另一个回答定义居中列的固定宽度。但是当我使用 p{...\columnwidth} 时也会出现问题。
在图形环境中一切正常。
如果更有经验的 LaTeX 用户能够提供帮助,我们将不胜感激!
我的文件:
\documentclass[jou, keeplastbox]{apa6}
\usepackage[american]{babel}
\usepackage{csquotes}
%TODO: ensure table width == columnwidth
\usepackage[para]{threeparttable}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\title{Title}
\shorttitle{Short Title}
\author{Susurration}
\affiliation{Void}
\abstract{This demonstration paper uses the \textsf{apa6} \LaTeX\
class to format the document in compliance with the 6th Edition of
the American Psychological Assocation's \textit{Publication Manual.}
The references are managed using \textsf{biblatex}.}
\keywords{APA style, demonstration}
\begin{document}
\maketitle
% this looks good but the defintion of widths is not very handy
% furthermore these width definitions seem to be sensitive to table content
\begin{table}[h]
\begin{threeparttable}
\caption{Looks good but width definitions are bad}
\label{tab:stimuli_domain}
\begin{tabular}{C{0.15\columnwidth}C{0.15\columnwidth}C{0.25\columnwidth}C{0.25\columnwidth}}
\toprule
\multicolumn{2}{c}{Cues} & \multicolumn{2}{c}{Stimuli} \\
Number\tabfnm{a} & Validity & A & B \\
\midrule
1 & 0.8 & 1 & 0 \\
2 & 0.6 & 0 & 0 \\
3 & 0.75 & 1 & 1 \\
\midrule
\end{tabular}
\begin{tablenotes}[para,flushleft]
{\small
\textit{Note.} Column 3 and Column 4 represent stimuli by assigning binary variables as given in equation \ref{eq:feature_def}.
}
\end{tablenotes}
\end{threeparttable}
\end{table}
% I would like to have this code to make span the table the whole column
\begin{table}[h]
\begin{threeparttable}
\caption{Looks bad but should look nice}
\label{tab:stimuli_domain_}
\begin{tabular}{C{0.2\columnwidth}C{0.2\columnwidth}C{0.4\columnwidth}C{0.4\columnwidth}}
\toprule
\multicolumn{2}{c}{Cues} & \multicolumn{2}{c}{Stimuli} \\
Number\tabfnm{a} & Validity & A & B \\
\midrule
1 & 0.8 & 1 & 0 \\
2 & 0.6 & 0 & 0 \\
3 & 0.75 & 1 & 1 \\
\midrule
\end{tabular}
\begin{tablenotes}[para,flushleft]
{\small
\textit{Note.} Column 3 and Column 4 represent stimuli by assigning binary variables as given in equation \ref{eq:feature_def}.
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案1
一个可能的解决方案是使用该tabularx
包。
\documentclass[jou, keeplastbox]{apa6}
\usepackage[american]{babel}
\usepackage{csquotes}
%TODO: ensure table width == columnwidth
\usepackage[para]{threeparttable}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\title{Title}
\shorttitle{Short Title}
\author{Susurration}
\affiliation{Void}
\abstract{This demonstration paper uses the \textsf{apa6} \LaTeX\
class to format the document in compliance with the 6th Edition of
the American Psychological Assocation's \textit{Publication Manual.}
The references are managed using \textsf{biblatex}.}
\keywords{APA style, demonstration}
\begin{document}
\maketitle
% this looks good but the defintion of widths is not very handy
% furthermore these width definitions seem to be sensitive to table content
\begin{table}[h]
\begin{threeparttable}
\caption{tabularx environment solves the problem}
\label{tab:stimuli_domain}
\begin{tabularx}{\columnwidth}{p{0.2\columnwidth}p{0.2\columnwidth}p{0.3\columnwidth}p{0.3\columnwidth}}
\toprule
\multicolumn{2}{c}{Cues} & \multicolumn{2}{c}{Stimuli} \\
Number\tabfnm{a} & Validity & A & B \\
\midrule
1 & 0.8 & 1 & 0 \\
2 & 0.6 & 0 & 0 \\
3 & 0.75 & 1 & 1 \\
\midrule
\end{tabularx}
\begin{tablenotes}[para,flushleft]
{\small
\textit{Note.} Column 3 and Column 4 represent stimuli by assigning binary variables as given in equation \ref{eq:feature_def}.
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\lipsum[1-2]
% I would like to have this code to make span the table the whole column
\begin{table}[h]
\begin{threeparttable}
\caption{tabularx environment solves the problem}
\label{tab:stimuli_domain_}
\begin{tabularx}{\columnwidth}{p{0.2\columnwidth}p{0.2\columnwidth}p{0.3\columnwidth}p{0.3\columnwidth}}
\toprule
\multicolumn{2}{c}{Cues} & \multicolumn{2}{c}{Stimuli} \\
Number\tabfnm{a} & Validity & A & B \\
\midrule
1 & 0.8 & 1 & 0 \\
2 & 0.6 & 0 & 0 \\
3 & 0.75 & 1 & 1 \\
\midrule
\end{tabularx}
\begin{tablenotes}[para,flushleft]
{\small
\textit{Note.} Column 3 and Column 4 represent stimuli by assigning binary variables as given in equation \ref{eq:feature_def}.
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\lipsum
\end{document}