robitex” post=75299Ciao,
ad un certo punto della procedura occorre fare un rapporto tra due lunghezze.
Poiché sia \divide che \dimexpr dividono solo per numeri interi, alla fine sono passato alla libreria \pgfmath, visto che l’avevo tra l’altro già disponibile perché caricata dal pacchetto pgfplots, superando il problema.Il codice completo è il seguente (la parte di codice che interessa la discussione è nel preambolo, e caso mai date un occhiata alla correttezza della costruzione della \vbox):
`
% make with 'Spectrum' Lua library
% !TEX encoding = UTF-8
% !TEX program = pdflatex\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}\usepackage{lmodern}
\usepackage{pgfplots}
\usepackage[output-decimal-marker={,},
arc-separator=\,]{siunitx}\pgfplotsset{compat=1.5}
\newbox\panel
\setbox\panel=\hbox{\rule{2pt}{0pt}\scriptsize
\vbox{%
\hbox{Sito: Carrara (MS)}
\hbox{Latidudine ED50 $\varphi=\ang{44;05;4.04}$}
\hbox{Longitudine ED50 $\lambda=\ang{10;06;16.27}$}
\hbox{Categoria di suolo: A}
\hbox{Categoria topografica T3 ($S_\mathrm{T}=\num{1.10}$)}}}\newdimen\hg
\hg=72mm\def\ymax{0.60}
\newdimen\yp
\yp=0pt
\advance\yp by \ht\panel
\advance\yp by \dp\panel
\advance\yp by 5pt% margine sup.\pgfmathparse{\ymax*(1-\yp/\hg)}
\let\ylegend\pgfmathresult\advance\yp by 5.6mm% spazio per legenda
\pgfmathparse{\ymax*(1-\yp/\hg)}
\let\ybox\pgfmathresult\begin{document}
\begin{tikzpicture}
\begin{axis}[scale only axis,
legend columns=4,
tick label style={font=\scriptsize},
xmin=0,
ylabel={$S_\mathrm{e}/g$},
ymin=0,
grid=major,
ymax=\ymax,
xmax=3.0,
xlabel={$T$ (s)},
width=115mm,
height=\hg,
variable=\T,
xtick={0.0,0.5,1.0,1.5,2.0,2.5,3.0},
legend style={draw=none, at={(axis cs:3.000, \ylegend)}}]\addplot coordinates {
(0.000, 0.214)
(0.099, 0.510)
(0.298, 0.510)
};
\addplot {0.15177/T};\addplot {0.36105/T^2};
\addplot coordinates {
(0.000, 0.167)
(0.096, 0.401)
(0.289, 0.401)
};
\addplot {0.11591/T};\addplot {0.25584/T^2};
\addplot coordinates {
(0.000, 0.067)
(0.084, 0.167)
(0.251, 0.167)
};
\addplot {0.04188/T};\addplot {0.07725/T^2};
\addplot coordinates {
(0.000, 0.054)
(0.080, 0.132)
(0.239, 0.132)
};
\addplot {0.03151/T};\addplot {0.05656/T^2};
% legenda spettri:
\legend{\textsc{slc},,,
\textsc{slv},,,
\textsc{sld},,,
\textsc{slo},,,
}
% add text info
\draw[black,fill=white]
(axis cs:3.000,\ybox) rectangle (axis cs:1.500,0.600)
node[anchor=north west]
{\box\panel};\end{axis}
\end{tikzpicture}
\end{document}`Grazie.
Non trascurerei la libreria l3fp. A giorni dovrebbe uscire l’aggiornamento in cui tutte le operazioni saranno espandibili come quelle con \numexpr e \dimexpr (che non è il caso di pgfmath).
Ciao
Enrico