4

I have the following table where on the 4th row I wish to add a box as in the picture attached. Just could not get around with it.

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

enter image description here

  • Just to make your question clear: you don't want to add a fourth column to your table but instead want to have something similar to a \marginpar? – Jan Dec 25 '16 at 08:06
  • 1
    Your MWE does not compile due to \input{preamble.tex}. BTW you don't have to sepcify .tex in that case. Your MWE will compile, if you add \usepackage{amsmath} instead. – Jan Dec 25 '16 at 08:07
  • No I do not want to add another column or row, instead I just want to add an arrow and a text box adjacent to 4th row to indicate that I am going to deal with it in Chapter 5. – shahrina ismail Dec 25 '16 at 08:08
  • 1
    The \bgroup/\egroup is not necessary, see Torbjørn T.'s answer here: http://tex.stackexchange.com/a/345639/101651. – CarLaTeX Dec 25 '16 at 20:42

3 Answers3

4

Although you don't want a fourth column, you might get off with exactly one (invisible) extra column. I changed the \hline into \cline{1-3} in order to make the last column invisible.

Code:

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

Output:

enter image description here

Jan
  • 5,293
3

An alternative solution with \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}

enter image description here

CarLaTeX
  • 62,716
3

I can't resit to make some refinements to nice CarLaTeX answer:

enter image description here

Diferences in MWE are indicated by % <-- ...:

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

Addendum: Similarly can be improved answer of Jan. With use of tabularx environment the forth column newer protrude right text margin. With \parbox the content of row is vertically centered:

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

which gives:

enter image description here

Addendum (2): Alternatively can be improved Jan's answer with use of cellspace. Using it the column type X from tabularx package can be redefined as:

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

what with makecell due to incompatibility between macros \makegapedcells and m{...} column type is not possible. With this change a \parbox used in addendum, is not needed anymore.

Use of cellspace require extension of column types with S, i,e. instead of c had to be used 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}

Obtained result is the same as before.

Zarko
  • 296,517
  • +1, thank you! Adding \usepackage{showframe} is clear that my solution goes out of the text margins, but why haven't I got a warning like "Overfull hbox..."? – CarLaTeX Dec 25 '16 at 18:27
  • Frankly said, I don't know. Similarly I don't know, why in Jan answer use of m{...} column style from array package doesn't work. I try to improve its answer too, but I didn't succeed. Its answer has problem with table protrusion out of text width too. – Zarko Dec 25 '16 at 18:38
  • Do you think I can ask a question about it? Maybe interesting... :) – CarLaTeX Dec 25 '16 at 18:44
  • Meanwhile I figured out the cause of problem: incompatibility of macro \makepagedcell and m{...} column type. Actually, I ask ones this question, however I can't temporary remember it and answer with detailed explanation. – Zarko Dec 25 '16 at 19:21