\tikzmark
항상 단일 셀 또는 a 전후 \multirow
, 그리고 a 후에도 작동합니다 \multicolumn
.
하지만~ 전에a \multicolumn
오류가 발생합니다.
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.55 \tikzmark{cmc}\multicolumn{2}{c}{A and B}
& C\tikzmark{dmc} \\
I expect to see \omit only after tab marks or the \cr of
an alignment. Proceed, and I'll ignore this case.
MWE는 다음과 같습니다.
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{tikzmark, calc}
\usepackage{array}
\usepackage{multirow}
\renewcommand{\arraystretch}{1.4}
\begin{document}
All these ones work:
\begin{tabular}{ccc}
\tikzmark{a}A & B & \tikzmark{b}C \\
D & E & F \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:a) -- (pic cs:b);
\end{tikzpicture}
\begin{tabular}{ccc}
A\tikzmark{c} & B & C\tikzmark{d} \\
D & E & F \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:c) -- (pic cs:d);
\end{tikzpicture}
\begin{tabular}{ccc}
\tikzmark{amr}\multirow{2}{*}{A and D} & B & \tikzmark{bmr}C \\
& E & F\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:amr) -- (pic cs:bmr);
\end{tikzpicture}
\begin{tabular}{ccc}
\multirow{2}{*}{A and D}\tikzmark{cmr} & B & C\tikzmark{dmr} \\
& E & F\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:cmr) -- (pic cs:dmr);
\end{tikzpicture}
\begin{tabular}{ccc}
\multicolumn{2}{c}{A and B}\tikzmark{amc} & C\tikzmark{bmc} \\
D & E & F \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:amc) -- (pic cs:bmc);
\end{tikzpicture}
But this one doesn't work:
\begin{tabular}{ccc}
\tikzmark{cmc}\multicolumn{2}{c}{A and B} & C\tikzmark{dmc} \\
D & E & F \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:cmc) -- (pic cs:dmc);
\end{tikzpicture}
\end{document}
답변1
텍스트(\null)로 간주되므로 \tikzmark
내부에 넣어야 합니다 . OTOH는 일정한 행 간격을 가정하여 다음 몇 행에 텍스트를 오버레이합니다. 와 거의 같습니다 .\multicolumn
\multirow
\smash{\begin{tabular}[t]...\end{tabular}}
참고로 가 \multicolumn
두 열보다 넓 으면 \hfill
s가 필요하지 않습니다.
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{tikzmark, calc}
\usepackage{array}
\usepackage{multirow}
\renewcommand{\arraystretch}{1.4}
\begin{document}
\begin{tabular}{ccc}
\multicolumn{2}{c}{\tikzmark{cmc}\hfill A and B\hfill\null} & C\tikzmark{dmc} \\
D wider & E & F \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\draw (pic cs:cmc) -- (pic cs:dmc);
\end{tikzpicture}
\end{document}