Re: Difficoltà con tikzmark

#82229
Up
0
Down
::


Alla fine ho risolto… senza [tt]\tikzmark[/tt] 😀 Ho usato semplicemente la libreria [tt]matrix[/tt], però ho avuto bisogno di rubare del codice dalla risposta di Andrew Stacey alla domanda Obstacles to simulating an amsmath matrix by a TiKZ matrix of math nodes su TeX Stack Exchange. In questo modo sono riuscito a rendere “piacevole” l’aspetto della matrice. Ottengo un triplice vantaggio: codice decisamente più semplice (niente posizioni definite con la sintassi partway), non c’è bisogno di aggiungere spazi bianchi manualmente, per esempio con [tt]\bigskip[/tt], è sufficiente compilare una sola volta 😀

Ecco il codice per chi fosse interessato:
`\documentclass[fleqn]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage[utf8]{inputenc}
\usepackage{lipsum,tikz}
\usetikzlibrary{calc,matrix}

\tikzset{
ams/.style={
baseline=-.7ex,
every left delimiter/.style={xshift=2pt},
every right delimiter/.style={xshift=-2pt},
every node/.style={inner sep=0pt},
},
ams matrix/.style={
inner sep=1pt,
column sep=1.5ex,
row sep=2\arraycolsep,
matrix of math nodes,
},
pmatrix/.style={
ams,
every matrix/.style={
ams matrix,
left delimiter={(},
right delimiter={)},
}
}
}

\begin{document}

\lipsum[3]
\begin{equation}
\begin{tikzpicture}[pmatrix]
\matrix (t)
{
T_{00} & T_{01} & T_{02} & T_{03} \\
T_{10} & T_{11} & T_{12} & T_{13} \\
T_{20} & T_{21} & T_{22} & T_{23} \\
T_{30} & T_{31} & T_{32} & T_{33} \\
} ;

% evidenzio tensore degli sforzi e flusso di impulso
\draw
(t-2-2.north west) —
(t-4-2.south west) —
(t-4-4.south east) —
(t-2-4.north east) — cycle;

% evidenzio pressione
\draw[fill,color=green,opacity=0.3]
(t-2-2.north west) —
(t-2-2.south west) —
(t-4-4.south west) —
(t-4-4.south east) —
(t-4-4.north east) —
(t-2-2.north east) — cycle;

% evidenzio densità di energia
\draw
(t-1-1.north west) —
(t-1-1.south west) —
(t-1-1.south east) —
(t-1-1.north east) — cycle;

% evidenzio densità di impulso
\draw
(t-2-1.north west) —
(t-4-1.south west) —
(t-4-1.south east) —
(t-2-1.north east) — cycle;

% evidenzio flusso di energia
\draw
(t-1-2.north west) —
(t-1-2.south west) —
(t-1-4.south east) —
(t-1-4.north east) — cycle;

\begin{scope}[font=\small]
\draw (t-1-3.north) — ++(0,20pt)
node[align=center,fill=white] {flusso di \\ energia};

\draw (t-1-1.north) — ++(0,20pt)
node[align=center,fill=white] {densità di \\ energia};

\draw (t-4-1.south) — ++(0,-25pt)
node[align=center,fill=white] {densità di \\ quantità \\ di moto};

\draw (t-4-4.east) — ++(35pt,0)
node[align=center,fill=white] {pressione};

\draw ($(t-2-4.east) – (.5pt,0)$) — ++(35pt,0)
node[align=center,fill=white] {stress};

\draw (t-4-3.south) — ++(0,-25pt)
node[align=center,fill=white] {flusso di \\ quantità \\ di moto};
\end{scope}
\end{tikzpicture}
\end{equation}
\lipsum[3]
\end{document}`

Sicuramente ho provato a usare [tt]\tikzmark[/tt] in un ambito sbagliato e me ne sono accorto subito, ma è stata l’occasione buona per studiare meglio il suo funzionamento. Grazie 🙂

Go to top