Estou tentando desenhar algumas decorações de cobra em uma caixa usando tikz
a biblioteca, mas não consegui o que desejo. Por que há desalinhamento entre as marcações reais e as cobras. Estou usando o seguinte código para isso.
\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}
Responder1
Pode ser que você tenha que ajustar a linha de base em
\newcommand{\tikzmark}[2]{%
\tikz[baseline=-0.5ex,overlay,remember picture] \node[text=black,
inner sep=2pt] (#1) {#2};}
obter
\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}