我对 LaTeX 还比较陌生,正在尝试为一系列解决方案创建表格。
我目前的基本代码是:
\documentclass[11pt, twoside, a4paper, openany]{memoir}
\usepackage[a4paper, inner=2cm, outer=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{booktabs,tabularx}
\usepackage{pifont}
\usepackage{accents}
\usepackage{amssymb}
\usepackage{bbding,enumitem}
\usepackage{ifetex}
\usepackage{mwe}
\usepackage{bbding}
\usepackage{calc}
\newcommand{\checked}[2][0.5cm]{%
\noindent\parbox[t]{#1}{\raggedright\ding{51}}\parbox[t]{\linewidth-#1}{#2}%
}
\setlength{\parindent}{0pt}
\begin{document}
\begin{table}[h]
\begin{tabular}{|>{\centering\arraybackslash}p{7.3cm}|p{7.3cm}|>{\centering\arraybackslash}p{1cm}|}
\hline
\textbf{Solutions} & \multicolumn{1}{c|}{\textbf{Specific Behaviours}} & \multicolumn{1}{c|}{\textbf{Point}}\\
\hline
If $z_1=3-2i$ is a root of $p(z)$ then $(z-3+2i)$ and $(z-3-2i)$ are factors. Likewise $p(-2)=0 \Rightarrow (z+2)$ is a factor.\\
$\begin{aligned}
p(z)&=(z-3+2i)(z-3-2i)(z+2)\\
&=(z^2-6z+13)(z+2)\\
&=z^3+2z^2-6z^2-12z+13z+26\\
&=z^3-4z^2+z+26
\end{aligned}$
&
\checked{Substitutes and expands.}
&
3.1.1 3.1.2 3.1.3\\
\hline
\end{tabular}
\end{table}
\end{document}
然而,当我排版代码时,它生成的表格不是我想要的或期望的。
由于某种原因,第二列中的文本与等式的中间对齐,而最后一列中的三个数字与此文本的顶部对齐。此外,最右侧列上的垂直边框似乎以命令开头\begin{aligned}
。
理想情况下,我希望第二列和第三列的文本与列顶部对齐。
答案1
像这样?
由于您加载了tabularx
包,我将在您的表中使用它。除此之外,我还将添加makecell
用于在单元格中添加一些小垂直空间的包,并将其\thead
命令用于列标题:
\documentclass[11pt, twoside, a4paper, openany]{memoir}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage{pifont}
\usepackage{amsmath}
\usepackage{booktabs, makecell, tabularx} % <---
\renewcommand\theadfont{\normalsize\bfseries} % <---
\renewcommand\theadgape{} % <---
\setcellgapes{3pt} % <---
\newcommand{\checked}[2][0.5cm]{%
\noindent\parbox[t]{#1}{\raggedright\ding{51}}\parbox[t]{\dimexpr\linewidth-#1}{#2}%
}
\begin{document}
\begin{table}[h]
\makegapedcells
\begin{tabularx}{\linewidth}{|>{\hsize=1.2\hsize}X
|>{\hsize=0.8\hsize}X
|>{\centering\arraybackslash}p{11mm}|}
\hline
\thead{Solutions} & \thead{Specific Behaviours} & \thead{Point} \\
\hline
If $z_1=3-2i$ is a root of $p(z)$ then $(z-3+2i)$ and $(z-3-2i)$ are factors. Likewise $p(-2)=0 \Rightarrow (z+2)$ is a factor.
\medskip
$\begin{aligned}
p(z)&=(z-3+2i)(z-3-2i)(z+2)\\
&=(z^2-6z+13)(z+2)\\
&=z^3+2z^2-6z^2-12z+13z+26\\
&=z^3-4z^2+z+26
\end{aligned}$
& \checked{Substitutes and expands.}
& 3.1.1 3.1.2 3.1.3\\
\hline
\end{tabularx}
\end{table}
\end{document}
或者像这样?
在上面的表格中,我认为您的表格主体有两行,这可以从您的 MWE 中得出。其中,表格主体的第一行缺少两个 & 符号,因此该行最后两个单元格缺少垂直线。
为了将第二列和第三列的文本与等式顶部对齐,您需要[t]
在环境中添加位置说明符aligned
:
\documentclass[11pt, twoside, a4paper, openany]{memoir}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage{pifont}
\usepackage{amsmath}
\usepackage{booktabs, makecell, tabularx} % <---
\renewcommand\theadfont{\normalsize\bfseries} % <---
\renewcommand\theadgape{} % <---
\setcellgapes{3pt} % <---
\newcommand{\checked}[2][0.5cm]{%
\noindent\parbox[t]{#1}{\raggedright\ding{51}}\parbox[t]{\dimexpr\linewidth-#1}{#2}%
}
\begin{document}
\begin{table}[h]
\makegapedcells
\begin{tabularx}{\linewidth}{|>{\hsize=1.2\hsize}X
|>{\hsize=0.8\hsize}X
|>{\centering\arraybackslash}p{11mm}|}
\hline
\thead{Solutions} & \thead{Specific Behaviours} & \thead{Point} \\
\hline
If $z_1=3-2i$ is a root of $p(z)$ then $(z-3+2i)$ and $(z-3-2i)$ are factors. Likewise $p(-2)=0 \Rightarrow (z+2)$ is a factor.
& & \\ % <---
$\begin{aligned}[t] % <---
p(z)&=(z-3+2i)(z-3-2i)(z+2)\\
&=(z^2-6z+13)(z+2)\\
&=z^3+2z^2-6z^2-12z+13z+26\\
&=z^3-4z^2+z+26
\end{aligned}$
& \checked{Substitutes and expands.}
& 3.1.1 3.1.2 3.1.3\\
\hline
\end{tabularx}
\end{table}
\end{document}
答案2
如果你把这个等式放在一个小页面中,它就可以起作用。
\documentclass[11pt, twoside, a4paper, openany]{memoir}
\usepackage[a4paper, inner=2cm, outer=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{amsmath}
\usepackage{pifont}
\newcommand{\checked}[2][0.5cm]{%
\noindent\parbox[t]{#1}{\raggedright\ding{51}}\parbox[t]{\the\dimexpr\linewidth-#1}{#2}%
}
\setlength{\parindent}{0pt}
\begin{document}
\begin{table}[h]
\begin{tabular}{|>{\centering\arraybackslash}p{7.3cm}|p{7.3cm}|>{\centering\arraybackslash}p{1cm}|}
\hline
\textbf{Solutions} & \multicolumn{1}{c|}{\textbf{Specific Behaviours}} & \multicolumn{1}{c|}{\textbf{Point}}\\
\hline
\begin{minipage}{7.3cm}
\centering
If $z_1=3-2i$ is a root of $p(z)$ then $(z-3+2i)$ and $(z-3-2i)$ are factors.
Likewise $p(-2)=0 \Rightarrow (z+2)$ is a factor.\\
$\begin{aligned}
p(z)&=(z-3+2i)(z-3-2i)(z+2)\\
&=(z^2-6z+13)(z+2)\\
&=z^3+2z^2-6z^2-12z+13z+26\\
&=z^3-4z^2+z+26
\end{aligned}$
\end{minipage}
&
\checked{Substitutes and expands.}
&
3.1.1 3.1.2 3.1.3\\
\hline
\end{tabular}
\end{table}
\end{document}
这是否漂亮是另一个问题。(我也改变了\checked
命令。)
答案3
这\arraybackslash
指令应仅针对最后的列,如果您打算\\
在前面使用。
事实上,如果从第一列规范中删除它,您会得到预期的输出:它的效果是使其\\
行为“在这里结束表格行”,这不是您想要的。
这是一个稍微不同的实现,您不需要猜测列宽。
\documentclass[11pt, twoside, a4paper, openany]{memoir}
\usepackage[a4paper, inner=2cm, outer=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{booktabs,tabularx}
\usepackage{pifont}
\usepackage{accents}
\usepackage{amssymb}
\usepackage{bbding,enumitem}
\usepackage{ifetex}
\usepackage{mwe}
\usepackage{bbding}
\usepackage{calc}
\newcommand{\checked}[2][0.5cm]{%
\noindent\parbox[t]{#1}{\raggedright\ding{51}}\parbox[t]{\linewidth-#1}{#2}%
}
\newcommand{\column}[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
\setlength{\parindent}{0pt}
\begin{document}
\begin{table}[htp]
\begin{tabularx}{\textwidth}{|>{\raggedright}X|X|c|}
\hline
\textbf{Solutions} &
\multicolumn{1}{c|}{\textbf{Specific Behaviours}} &
\multicolumn{1}{c|}{\textbf{Point}}\\
\hline
If $z_1=3-2i$ is a root of $p(z)$ then $(z-3+2i)$ and $(z-3-2i)$ are factors.
Likewise $p(-2)=0 \Rightarrow (z+2)$ is a factor.
\centering
$\begin{aligned}[t]
p(z)&=(z-3+2i)(z-3-2i)(z+2)\\
&=(z^2-6z+13)(z+2)\\
&=z^3+2z^2-6z^2-12z+13z+26\\
&=z^3-4z^2+z+26
\end{aligned}$
&
\checked{Substitutes and expands.}
&
\column{3.1.1 \\ 3.1.2 \\ 3.1.3} \\
\hline
\end{tabularx}
\end{table}
\end{document}
我留下了所有的包,但我不认为你需要所有的包,特别是ifetex
,也不是mwe
。