看看我在做什么这里。
我设法想出的 MWE 如下:
\documentclass[12pt]{article}
\usepackage{makecell}
\usepackage{cals}
\begin{document}
\begin{tabular}{|p{4cm}|c|p{3.5cm}|}\hline
\diaghead{\theadfont Appeals to agent causality explanation}%
{Preferred type\\of cognitive processing}{Appeals to agent explanation/\\causality}&
\thead{Unrestricted}&\thead{Restricted}\\ \hline
\vspace{1cm}
Reflective & 1. Theology & 2. Science\\ \hline
\vspace{1cm}
Maturationally natural & 3. Popular religion & 4. Commonsense explanations and understandings of the non-social world\\ \hline
\end{tabular}
\end{document}
由此产生了如下结果:
但是有些行和列的格式很乱,有些列居中,有些不居中,有些行居中,有些不居中,而且单词会不必要地跨行。有人能帮我改正一下,让我更接近原文吗?谢谢。
答案1
这是使用 TikZ 节点和库的解决方案positioning
。我相信可以做得更优雅。但是,如果你有兴趣调整这个就这样,这可能是一个适合您的解决方案。
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\begin{document}
\begin{tikzpicture}[
node distance=0pt,
%% h=horizontal, v=vertical
%% l=left, m=middle, r=right,
%% t=top, b=bottom,
%% w=width, h=height
hlw/.style={minimum width=2.5in},
hmw/.style={minimum width=1.75in},
hrw/.style={minimum width=2in},
vth/.style={minimum height=1in},
vmh/.style={minimum height=1in},
vbh/.style={minimum height=1.25in},
%%
my corner stone/.style={vth,hlw,draw},
%%
my text/.style={text width=1.5in},
my corner stone top/.style={text width=1.5in,align=flush right,anchor=north east},
my corner stone bot/.style={text width=1.5in,align=flush left,anchor=south west},
]
\node[outer sep=0pt,my corner stone] (corner stone) at (0,0) {};
\draw (corner stone.north west) -- (corner stone.south east);
%% top labels
\node[right =of corner stone,hmw,vth,draw] (unrestricted square) {Unrestricted};
\node[right =of unrestricted square,hrw,vth,draw] (restricted square) {Restricted};
%% side labels
\node[below=of corner stone,hlw,vmh,draw] (reflective) {Reflective};
\node[below=of reflective,hlw,vbh,draw] (mature) {Maturationally natural};
%% contents
\node[right=of reflective,hmw,vmh,draw] (theology) {Theology};
\node[right=of theology,hrw,vmh,draw] (science) {Science};
\node[right=of mature,hmw,vbh,draw] (popular) {Popular religion};
\node[right=of popular,hrw,vbh,draw,my text] (long) {Common sense explanations and understandings of the non-sensical world};
\node[my corner stone top] at (corner stone.north east) {Appeals to agent explanation/causality};
\node[my corner stone bot] at (corner stone.south west) {Preferred type of cognitive processing};
\foreach \myn [count=\myi] in {theology,science,popular,long}
{
\node[anchor=north west] at (\myn.north west) {\myi};
}
\end{tikzpicture}
\end{document}
答案2
那么,为什么不去掉那个丑陋的对角线单元格呢?试试这个:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}\centering
\setlength{\tabcolsep}{4mm}
\begin{tabular}{@{}lll@{}}\toprule
& \multicolumn{2}{c}{Appeals to agent} \\
& \multicolumn{2}{c}{explanation/causality}\\ \cmidrule(lr){2-3}
Preferred type of &&\\
cognitive processing & \multicolumn{1}{c}{\textbf{Unrestricted}} & \multicolumn{1}{c}{\textbf{Restricted}} \\ \cmidrule(r){1-1}\cmidrule(l){2-3}
\textbf{Reflective} & 1. Theology & 2. Science\\
\textbf{Maturationally natural} & 3. Popular religion & 4. Commonsense explana-\\
&& tions and understandings \\
&& of the non-social world\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
我建议完全不同的东西。它并不完美,但我认为看起来更好。我不懂德语,但所有命令都是从 Axel Reichter 那里偷来的表格内容。
\documentclass[12pt]{article}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\newcommand{\armultirow}[3]{%
\multicolumn{#1}{#2}{%
\begin{picture}(0,0)%
\put(0,0){%
\begin{tabular}[b]{@{}#2@{}}%
#3%
\end{tabular}%
}%
\end{picture}%
}%
}%
\newcolumntype{H}[1]{%
>{\bfseries\centering\hspace{0pt}}m{#1}%
}
\newcolumntype{L}[1]{%
>{\bfseries\raggedright\arraybackslash\hspace{0pt}}p{#1}%
}
\newcolumntype{P}[1]{%
>{\raggedright\arraybackslash\hspace{0pt}}p{#1}%
}
\begin{tabular}{P{4cm}P{3.5cm}P{3.5cm}}
\armultirow{1}{L{4cm}}{Preferred type of cognitive processing}
& \multicolumn{2}{H{7.5cm}}{Appeals to agent causality explanation/causality} \\
\cmidrule(lr){2-3}
& \multicolumn{1}{c}{Unrestricted} & \multicolumn{1}{c}{Restricted} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
Refective & 1. Theology & 2. Science\\[1ex]
Maturationally natural & 3. Popular religion & 4. Commonsense explanations and understandings of the non-social world\\
\bottomrule
\end{tabular}
\end{document}
答案4
对于中间对齐的段落单元格,您应该使用m
列而不是p
一列,一列用于顶部对齐的单元格。
然后,对于水平居中,您需要加载array
包并将其添加>{\centering\arraybackslash}
到要居中的列的前面。
对于断字,我认为这是因为你限制了列的大小。尝试增加它或让 LaTeX 选择。
最后,不要使用\vspace
s。使用\setcellgapes
和\makegapedcells
。
\documentclass[12pt]{article}
\usepackage{array}
\usepackage{makecell}
\usepackage{cals}
\setcellgapes{8pt}
\begin{document}
\begingroup
\makegapedcells
\begin{tabular}{|>{\centering\arraybackslash}m{4cm}|c|>{\centering\arraybackslash}m{3.5cm}|}\hline
\diaghead{\theadfont Appeals to agent causality explanation}%
{Preferred type\\of cognitive processing}{Appeals to agent explanation/\\causality}&
\thead{Unrestricted}&\thead{Restricted}\\ \hline
Reflective & 1. Theology & 2. Science\\ \hline
Maturationally natural & 3. Popular religion & 4. Commonsense explanations and understandings of the non-social world\\ \hline
\end{tabular}
\endgroup
\end{document}