在表格旁边添加箭头和文本框

在表格旁边添加箭头和文本框

我有一张下表,我想在第四行添加一个方框,如附图所示。但就是没办法。

\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列类型重新定义为:Xtabularx

\renewcommand\tabularxcolumn[1]{m{#1}}% 

makecell由于宏\makegapedcells和列类型不兼容,因此m{...}无法实现。通过此更改\parbox,不再需要附录中使用的内容。

使用cellspace需要扩展列类型,即必须使用S而不是:cSc

\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}

得到的结果和以前相同。

相关内容