Re: Ridefinire \@makecaption e \caption

#59002
Up
0
Down
::


Ciao,

ecco la soluzione che ho trovato
`
%%%%%%%%%%%%%%%%
% FLOAT FIGURE %
%%%%%%%%%%%%%%%%
%\def\StarTrekFontScreen{\setromanfont{SWISS 911 UCm BT}}

\newlength\@figureWidth
%\show\fnum@figure

\newlength\@captionHeight
%\show\@captionHeight

\newenvironment*{tikzgraphic}[5]{%
% #1 = h t p oppure b
% #2 = total picture width(cm)
% #3 = picture name
% #4 = caption
% #5 = label
\@float{figure}[#1]
\centering
\def\@CAP{#4}
\def\@LAB{#5}

\begin{tikzpicture}[remember picture]
\def\@Ydist{1.5ex}
\def\@Xdist{1ex}
\def\@YH{5ex}
\def\@topHeight{.4cm}
\def\@bigRadius{.5cm}
\def\@smallRadius{.1cm}

\pgfmathsetlength{\@figureWidth}{(#2-(2*(\@Xdist+\@YH)))}
\node[inner sep=-\pgflinewidth/2] (figure) at (0,0){\includegraphics[width=\@figureWidth]{#3}};

\advance \c@figure by 1

\node[minimum width = \@figureWidth,
anchor = north west,
fill = \mycolor,
draw = \mycolor,
inner xsep = 1ex,
inner ysep = 1ex] (caption) at ($(figure.south west)+(0,-\@Ydist)$)
{\begin{minipage}{\@figureWidth-2ex}
{\StarTrekFontScreen\Large \fnum@figure}

{\normalsize #4}
\end{minipage}};

\getheightofnode{\@captionHeight}{caption}

\node[anchor = south,
minimum width = \@figureWidth,
minimum height = \@topHeight,
fill = \mycolor,
draw = \mycolor] (top) at ($(figure.north)+(0,\@Ydist)$){};

\foreach \sign/\loc in {+/east,-/west}{
\coordinate (E\loc) at ($(caption.south \loc)+(\sign\@Xdist,0)$);
\coordinate (F\loc) at ($(E\loc)+(0,\@captionHeight)$);
\coordinate (H\loc) at ($(top.north \loc)+(\sign\@Xdist,0)$);
\coordinate (G\loc) at ($(top.south \loc)+(\sign\@Xdist,0)$);
\fill[HEAD] (E\loc)arc[radius=\@bigRadius,start angle=-90,delta angle=\sign90]–
($(H\loc)+(\sign\@bigRadius,-\@bigRadius)$)
arc[radius=\@bigRadius,start angle={90-\sign 90},delta angle=\sign90]–
(G\loc)
arc[radius=\@smallRadius,start angle=90,delta angle=-\sign90]–
($(F\loc)+(\sign\@smallRadius,\@smallRadius)$)
arc[radius=\@smallRadius,start angle={90-\sign 90},delta angle=-\sign90]–
cycle;}
}{\end{tikzpicture}
\caption{\@CAP}\label{\@LAB}\end@float}

%%%%%%%%%%%
% CAPTION %
%%%%%%%%%%%
\long\def\@makecaption#1#2{%
\advance \c@figure by -1
}
`

Codice da far girare con XeLaTeX o LuaLaTeX oppure togiere la riga in cui si definisce un font che ho installato sul mio OS.

L’idea è questa…

Praticamente ho imbrogliato il comando caption perché scrivo la didascalia come nodo nell’ambiente tikzpicture dove nelle righe precedendi faccio avanzare il counter \c@figure
per mettere il numero giusto(altrimenti LaTeX stamperebbe tutti i numeri meno uno).

Il comando \@makecaption invece lo svuoto completamente, lasciando comunque due input, e lo sostituisco con una sottrazione di uno del counter \c@figure.

Il risultato si può vedere qui sotto

Che ne dite? avreste affrontato il problema in modo diverso?

Ora l’ulteriore passo è adattare il tutto, magari creando ambienti apposta, a tabelle, figure create con tikz e pgfplots e la cosa più difficile(immagino) adattarlo a delle subfigure create con il pacchetto subfig.

Michele

Go to top