Re: Le mie (dis)avventure con TikZ

#96782
Up
0
Down
::

Liverpool” post=99045

`\newcommand{\sottolinea}[2][]{%
\begin{tikzpicture}[baseline=-.5ex]\node[inner sep=0pt,outer sep=-1pt](x){$#2$};
\draw[#1]([yshift=-1.5pt]x.south west)–([yshift=-1.5pt]x.south east);
\end{tikzpicture}%
}`

A me sembra che vada benone. Perché dici che la spaziatura matematica non è rispettata? E che ne dici di questa minima variante?
`\newcommand{\sottolinea}[2][]{%
\begin{tikzpicture}[baseline=0]
\node [anchor=base, inner xsep=0, inner ysep=1.2bp, outer sep=-0.1em] (x) {$#2$};
\draw[#1] (x.south west) — (x.south east);
\end{tikzpicture}%
}`

In effetti pare sia corretto. Con il seguente esempio l’ho verificato tenendo presente come riferimento il segno +: `
\documentclass{article}
\usepackage{amsmath,amssymb,tikz}
\usetikzlibrary{calc,matrix}

\newcommand{\tikzmark}[2][]{\tikz[remember picture]\node[#1,coordinate](#2){};}

\newcommand{\sottolinea}[2][]{%
\begin{tikzpicture}[baseline=0]
\node [anchor=base, inner xsep=0, inner ysep=1.2bp, outer sep=-0.1em] (x) {$#2$};
\draw[#1] (x.south west) — (x.south east);
\end{tikzpicture}%
}

\newcommand{\oldsottolinea}[2][]{%
\begin{tikzpicture}[baseline=0]
\node [anchor=base, inner xsep=0, inner ysep=1.2bp, outer sep=-0.1em] (x) {$#2$};
\draw[#1] (x.south west) — (x.south east);
\end{tikzpicture}%
}

\begin{document}
$\tikzmark{a}x-\sottolinea[red!80!black]{A+B}+\sottolinea[blue!60!cyan,dashed]{y+z}\tikzmark[shift={(5.75pt,0)}]{c}+C$ \qquad $x-A+B+y+z+C\tikzmark{b}$% <= per confronto $x-A+B+y+z\tikzmark[shift={(5.75pt,0)}]{d}+C$% <= per confronto \begin{tikzpicture}[remember picture, overlay] \draw[dotted] (a.south)--(b.south); \draw[green!70!black] ([yshift=3mm]c.north)--([yshift=-1mm]d.center); \end{tikzpicture} $\tikzmark{a1}x-\oldsottolinea[red!80!black]{A+B}+\oldsottolinea[blue!60!cyan,dashed]{y+z}\tikzmark[shift={(5.75pt,0)}]{c1}+C$ \qquad $x-A+B+y+z+C\tikzmark{b1}$% <= per confronto $x-A+B+y+z\tikzmark[shift={(5.75pt,0)}]{d1}+C$% <= per confronto \begin{tikzpicture}[remember picture, overlay] \draw[dotted] (a1.south)--(b1.south); \draw[green!70!black] ([yshift=3mm]c1.north)--([yshift=-1mm]d1.center); \end{tikzpicture} \end{document} ` Il risultato (meglio verificare con la propria macchina e a un buon livello di zoom ;) ) [attachment=1235]Schermatadel2015-01-04091614.png[/attachment] Ciao Claudio

Attachments:
You must be logged in to view attached files.

Go to top