
누군가 이 예와 같이 테이블의 일부 열과 행을 통과하는 선을 어떻게 그릴 수 있는지 말해 줄 수 있습니까?
예를 들어 a,b,c 행을 가로지르는 선
\documentclass{article}
\usepackage{float}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|}
\hline
a & b & c \\
\hline
d & e & f \\
\hline
h & i & j \\
\hline
\end{tabular}
\end{table}
\end{document}
미리 감사드립니다.
답변1
한 가지 가능성은 Ti를 사용하는 것입니다.케이Z와 tikzmark
.
\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|}
\hline
\tikzmarknode{a}{a} & b & \tikzmarknode{c}{c} \\
\hline
d & e & f \\
\hline
h & i & j \\
\hline
\end{tabular}%
\begin{tikzpicture}[overlay,remember picture]
\draw[thick,red,-stealth] ([xshift=-1ex]a.west) -- ([xshift=1ex]c.east);
\end{tikzpicture}%
\end{table}
\end{document}
\tikzmarknode
is 의 구문 \tikzmarknode{<id>}{<content>}
에서 는 id
식별자이고 content
는 내용입니다. 따라서 1
대신 을 원하는 경우 a
동일한 식별자를 사용하고 두 번째 인수인 \tikzmarknode{a}{1}
. 그러면 테이블에 1이 표시됩니다.
\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|}
\hline
\tikzmarknode{a}{1} & 2 & \tikzmarknode{c}{3} \\
\hline
\tikzmarknode{goat}{d} & e & f \\
\hline
\tikzmarknode{duck}{h} & i & j \\
\hline
\end{tabular}%
\begin{tikzpicture}[overlay,remember picture]
\path[left color=blue,right color=red]
([xshift=-1ex,yshift=-0.3pt]a.west) rectangle ([xshift=1ex,yshift=0.3pt]c.east);
\draw[red,shorten >=-0.2ex,shorten <=-0.2ex] (goat.north) -- (duck.south);
\end{tikzpicture}%
\end{table}
\end{document}
이 예는 또한 Ti를 사용하여 이를 설명하기 위한 것입니다.케이Z 단색 선을 훨씬 뛰어넘을 수 있습니다.
답변2
기본 도구만 사용:
\documentclass{article}
\usepackage{float}
\usepackage[table, svgnames]{xcolor}
\usepackage{hhline, array}
\begin{document}
\begin{table}[H]
\centering\setlength{\extrarowheight}{1pt}
\begin{tabular}{|c|c|c|}
\hhline{|---|}
\noalign{\vskip \dimexpr1.5ex + 1pt-0.4pt\relax}
\hhline{>{\arrayrulecolor{Crimson}}--->{\arrayrulecolor{black}}|}
\noalign{\vskip\dimexpr-1.5ex- 1pt\relax}
a & b & c \\
\hhline{|---|}
d & e & f \\
\hhline{|---|}
h & i & j \\
\hhline{|---|}
\end{tabular}
\end{table}
\end{document}
답변3
이를 수행하는 또 다른 방법은 다음과 같습니다.
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\begin{center}
\begin{tikzpicture}
\foreach \x in {0,2,...,6} \draw[thick] (\x,0)--(\x,6);
\foreach \x in {0,2,...,6} \draw[thick] (0,\x)--(6,\x);
\node at (1.5,1.5) {$g$};
\node at (3.5,1.5) {$h$};
\node at (5.5,1.5) {$i$};
\node at (1.5,3.5) {$d$};
\node at (3.5,3.5) {$e$};
\node at (5.5,3.5) {$f$};
\node at (1.5,5.5) {$a$};
\node at (3.5,5.5) {$b$};
\node at (5.5,5.5) {$c$};
\color{magenta}
\draw[thick,-] (8,2.5)--(0,2.5);
\color{cyan}
\draw[thick,-] (5,6)--(5,0);
\color{green}
\draw[thick,->] (.5,0)--(.5,7);
\end{tikzpicture}
\end{center}
\end{document}
디스플레이
메모. 이 경우 나는 table
당신처럼 환경을 사용하지 않습니다. 동일한 결과를 표시하려면 이를 대안으로 사용하십시오.
내 질문에 대한 @JoséCarlosSantos의 답변에서 영감을 받아 이 작업을 수행했습니다.표 안에 화살표와 숫자를 어떻게 추가할 수 있나요?