我有一张下表,我想在第四行添加一个方框,如附图所示。但就是没办法。
\documentclass[12pt,a4paper,twoside]{report}
\input{preamble.tex}
\begin{document}
\begin{table}
\centering
\bgroup
\def\arraystretch{2.0}
\begin{tabular}{|c|c|c|}
\hline
$\mu \in Y$& Condition applied on $\delta(\mu)$ & Implication upon lifting \\ \hline
$-4$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k-4 \pmod{2k}$ \\ \hline
$-3$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-3 \pmod{2k}$ \\ \hline
$-2$ & - & - \\ \hline
$-1$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-1 \pmod{2k}$ \\ \hline
$0$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k \pmod{2k}$ \\ \hline
$3$ & $\bigg(\dfrac{5333\cdot97324757}{q}=-1\bigg)$ & $n \not\equiv k+3 \pmod{2k}$ \\ \hline
\end{tabular}
\egroup
\caption{Conditions following from pushing up modulus.\label{condition}}
\end{table}
\end{document}
答案1
尽管您不需要第四列,但您可能只需要一个(不可见的)额外列。我将 改为 ,\hline
以\cline{1-3}
使最后一列不可见。
代码:
\documentclass[12pt,a4paper,twoside]{report}
% \input{preamble.tex}
\usepackage{amsmath}
\begin{document}
\begin{table}
\centering
\bgroup
\def\arraystretch{2.0}
\begin{tabular}{|c|c|c|p{4cm}}
\cline{1-3}
$\mu \in Y$& Condition applied on $\delta(\mu)$ & Implication upon lifting \\ \cline{1-3}
$-4$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k-4 \pmod{2k}$ \\ \cline{1-3}
$-3$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-3 \pmod{2k}$ \\ \cline{1-3}
$-2$ & - & - & $\rightarrow$ refer Theorem $x$ in Section $y$ of
chapter 5 \\ \cline{1-3}
$-1$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-1 \pmod{2k}$ \\ \cline{1-3}
$0$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k \pmod{2k}$ \\ \cline{1-3}
$3$ & $\bigg(\dfrac{5333\cdot97324757}{q}=-1\bigg)$ & $n \not\equiv k+3 \pmod{2k}$ \\ \cline{1-3}
\end{tabular}
\egroup
\caption{Conditions following from pushing up modulus.\label{condition}}
\end{table}
\end{document}
输出:
答案2
另一种解决方案是\tikzmark
:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows, tikzmark, calc}
\begin{document}
\begin{table}
\centering
\bgroup
\def\arraystretch{2.0}
\begin{tabular}{|c|c|c|}
\hline
$\mu \in Y$& Condition applied on $\delta(\mu)$ & Implication upon lifting \\ \hline
$-4$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k-4 \pmod{2k}$ \\ \hline
$-3$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-3 \pmod{2k}$ \\ \hline
$-2$ & - & - \tikzmark{here} \\ \hline
$-1$ & $\bigg(\dfrac{5\cdot29}{q}=-1\bigg)$ & $n \not\equiv k-1 \pmod{2k}$ \\ \hline
$0$ & $\bigg(\dfrac{13\cdot1789}{q}=-1\bigg)$ & $n \not\equiv k \pmod{2k}$ \\ \hline
$3$ & $\bigg(\dfrac{5333\cdot97324757}{q}=-1\bigg)$ & $n \not\equiv k+3 \pmod{2k}$ \\ \hline
\end{tabular}
\egroup
\caption{Conditions following from pushing up modulus.\label{condition}}
\end{table}
\begin{tikzpicture}[overlay,remember picture]
\node at ($(pic cs:here)+(2.7,0.1)$) {$\rightarrow$};
\node[draw, rounded corners, align=left] at ($(pic cs:here)+(5,0.2)$) {%
Refer Theorem \dots \\ in Section \dots \\ of Chapter 5
};
\end{tikzpicture}
\end{document}
答案3
我忍不住对 CarLaTeX 的优秀答案做了一些改进:
MWE 的差异通过以下方式表示% <-- ...
:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{amsmath, amssymb}
\usepackage{makecell}% <-- added
\usepackage{tikz}
\usetikzlibrary{arrows, calc, positioning, tikzmark}
\usepackage[showframe]{geometry}
\begin{document}
\begin{table}
\setcellgapes{5pt}% <-- added
\makegapedcells % <-- added
\small
\setlength\tabcolsep{4pt}
% \bgroup % <-- its purpose is not clear, so I delete it
\begin{tabular}{|*{3}{>{$\displaystyle}c<{$}|}}% <-- changed
\hline
\mu \in Y
& \text{Condition applied on }\delta(\mu) & \text{Implication upon lifting} \\ \hline
-4 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k-4 \pmod{2k} \\ \hline
-3 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-3 \pmod{2k} \\ \hline
-2 & \vphantom{\frac{A}{B}} - % <-- added
& - \tikzmark{here} \\ \hline
-1 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-1 \pmod{2k} \\ \hline
0 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k \pmod{2k} \\ \hline
3 & \left(\frac{5333\cdot97324757}{q}=-1\right) & n \not\equiv k+3 \pmod{2k} \\ \hline
\end{tabular}
% \egroup
\caption{Conditions following from pushing up modulus.}
\label{condition}
\end{table}
\begin{tikzpicture}[overlay,remember picture,node distance=20mm]
\node[right=of pic cs:here] (a) {$\rightarrow$};
\node[draw, rounded corners, align=left, right=0mm of a] {%
Refer Theorem \dots \\ in Section \dots \\ of Chapter 5 };
\end{tikzpicture}
\end{document}
附录:
同样可以改进 1 月的答案。使用tabularx
环境时,第四列较新的文本突出右侧边距。\parbox
行的内容垂直居中:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{amsmath, amssymb}
\usepackage{makecell, tabularx}% <-- added
\usepackage{array}
\usepackage[showframe]{geometry}
\begin{document}
\begin{table}
\setcellgapes{5pt}% <-- added
\makegapedcells % <-- added
\setlength\tabcolsep{4pt}% <-- changed
\small
\begin{tabularx}{\textwidth}{|*{3}{>{$\displaystyle}c<{$}|}X}% <-- changed
\cline{1-3}
\mu \in Y
& \text{Condition applied on }\delta(\mu) & \text{Implication upon lifting} \\\cline{1-3}
& \text{Condition applied on }\delta(\mu) & \text{Implication upon lifting} \\\cline{1-3} \cline{1-3}
-4 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k-4 \pmod{2k} \\\cline{1-3}
-3 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-3 \pmod{2k} \\\cline{1-3}
-2 & - & - & \parbox{\linewidth}{\raggedright% <-- added
$\rightarrow$ refer Theorem $x$ in Section $y$ of chapter 5} \\\cline{1-3}
-1 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-1 \pmod{2k} \\\cline{1-3}
0 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k \pmod{2k} \\\cline{1-3}
3 & \left(\frac{5333\cdot97324757}{q}=-1\right) & n \not\equiv k+3 \pmod{2k} \\\cline{1-3}
\cline{1-3}
\end{tabularx}
\end{table}
\end{document}
这使:
附录(2):
或者,可以使用 来改进 Jan 的答案。使用它可以将包中的cellspace
列类型重新定义为:X
tabularx
\renewcommand\tabularxcolumn[1]{m{#1}}%
makecell
由于宏\makegapedcells
和列类型不兼容,因此m{...}
无法实现。通过此更改\parbox
,不再需要附录中使用的内容。
使用cellspace
需要扩展列类型,即必须使用S
而不是:c
Sc
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{amsmath, amssymb}
\usepackage{cellspace, tabularx}% <-- added
\renewcommand\tabularxcolumn[1]{m{#1}}% <-- added
\usepackage{array}
\usepackage[showframe]{geometry}
\begin{document}
\begin{table}
\setlength\cellspacetoplimit{5pt} % <-- added
\setlength\cellspacebottomlimit{5pt} % <-- added
\setlength\tabcolsep{4pt}% <-- changed
\small
\begin{tabularx}{\textwidth}{|*{3}{>{$\displaystyle}Sc<{$}|}
>{\raggedright\arraybackslash} X}% <-- changed
\cline{1-3}
\mu \in Y
& \text{Condition applied on }\delta(\mu) & \text{Implication upon lifting} \\\cline{1-3}
& \text{Condition applied on }\delta(\mu) & \text{Implication upon lifting} \\\cline{1-3} \cline{1-3}
-4 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k-4 \pmod{2k} \\\cline{1-3}
-3 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-3 \pmod{2k} \\\cline{1-3}
-2 & - & - & $\rightarrow$ refer Theorem $x$ in Section $y$ of chapter 5 \\\cline{1-3}
-1 & \left(\frac{5\cdot29}{q}=-1\right) & n \not\equiv k-1 \pmod{2k} \\\cline{1-3}
0 & \left(\frac{13\cdot1789}{q}=-1\right) & n \not\equiv k \pmod{2k} \\\cline{1-3}
3 & \left(\frac{5333\cdot97324757}{q}=-1\right) & n \not\equiv k+3 \pmod{2k} \\\cline{1-3}
\cline{1-3}
\end{tabularx}
\end{table}
\end{document}
得到的结果和以前相同。