라이브러리를 사용하여 상자에 뱀 장식을 그리려고 하는데 tikz
원하는 것을 얻을 수 없습니다. 실제 표시와 뱀 사이에 잘못된 정렬이 있는 이유는 무엇입니까? 이를 위해 다음 코드를 사용하고 있습니다.
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing, shapes, arrows, shadows, positioning}
\newcommand{\tikzmark}[2]{%
\tikz[overlay,remember picture] \node[text=black,
inner sep=2pt] (#1) {#2};}
\begin{document}
\begin{figure}[ht]
\centering
\tikzstyle{box}=[draw, fill=pink!10, text centered, drop shadow]
\begin{tikzpicture}[overlay, remember picture]
\node (main) [box, minimum height=20em, minimum width=10em,align=left]
{
\tikzmark{a}{}xxxxxxxx\tikzmark{b}{}\\
\tikzmark{c}{}xxxxxxxx\tikzmark{d}{}\\
};
\draw [-,decorate,decoration=snake] (a.center) -- (b.center);
\draw [-,decorate,decoration=snake] (c.center) -- (d.center);
\end{tikzpicture}
\end{figure}
\end{document}
답변1
기준선을 조정해야 할 수도 있습니다.
\newcommand{\tikzmark}[2]{%
\tikz[baseline=-0.5ex,overlay,remember picture] \node[text=black,
inner sep=2pt] (#1) {#2};}
얻기 위해
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing, shapes, arrows, shadows, positioning}
\newcommand{\tikzmark}[2]{%
\tikz[baseline=-0.5ex,overlay,remember picture] \node[text=black,
inner sep=2pt] (#1) {#2};}
\begin{document}
\begin{figure}[ht]
\centering
\tikzstyle{box}=[draw, fill=pink!10, text centered, drop shadow]
\begin{tikzpicture}[overlay, remember picture]
\node (main) [box, minimum height=20em, minimum width=10em,align=left]
{
\tikzmark{a}{}xxxxxxxx\tikzmark{b}{}\\
\tikzmark{c}{}xxxxxxxx\tikzmark{d}{}\\
};
\draw [-,decorate,decoration=snake] (a.center) -- (b.center);
\draw [-,decorate,decoration=snake] (c.center) -- (d.center);
\end{tikzpicture}
\end{figure}
\end{document}