Visualizzazione post con etichetta subfigure. Mostra tutti i post
Visualizzazione post con etichetta subfigure. Mostra tutti i post

lunedì 26 ottobre 2015

Incorrect reference to figure: the role of caption and centering

Recently I wrote a document structured mostly as a bullet point and with a lot of figures.
Everything went fine except that occasionally the figures would be referred with the wrong number, altough no mistake was made in the code.
A part the already known problem of putting the label -after- the caption, it turned out that the responsable was also the \centering, by somehow messing up with the labeling system.
The solution is to use the center environment as a replacement of \centering (here demonstrated with multiple figures):

\begin{figure}[!ht]
\begin{center}
\subfigure[]{
\includegraphics[width = 0.4\textwidth]{figures/ImageA.JPG}}%
\subfigure[]{
\includegraphics[width = 0.4\textwidth]{figures/ImageB.JPG}}%
\\
\subfigure[]{
\includegraphics[width = 0.4\textwidth]{figures/ImageC.JPG}}%
\subfigure[]{
\includegraphics[width = 0.4\textwidth]{figures/ImageD.JPG}}%
\caption{Some caption.}
\end{center}
\label{SomeLabel}
\end{figure}

Problem solved!

giovedì 30 agosto 2012

Figure multiple - sottofigure

Utilizzando il pacchetto
  • subfigure
e' possibile affiancare o sovrappore piu' sottofigure nella stessa figura, di seguito il codice base:

\begin{figure}[posizione] \centering
\subfigure[caption sottofigura 1]{
           \includegraphics[opzioni] {subfigure1.eps} \label{label della sottofigura 1}
                                                         }% non mettere linee vuote perche' altrimenti le figure vengono messe una sopra l'altra invece che affiancate
\subfigure[caption sottofigura 1]{
           \includegraphics[opzioni] {subfigure1.eps} \label{label della sottofigura 1}
                                                         } \label{label dell'intera figura}
\caption{caption dell'intera figura}
\end{figure} 
[posizione] ed [opzioni] sono utilizzati nella stessa maniera del tradizionale ambiente \begin{figure} ... \end{figure}, cosi' come \label e \caption delle ultime tre righe, allo stesso modo il \label interno ai comandi \subfigure definisce l'etichetta delle sole sottofigure e l'opzionale caption tra parentesi quadre appena dopo il comando \subfigure definisce la loro didascalia.
Per sistemare le figure in maniera verticale, e' sufficiente inserire una doppia backslash ( \\ ) per mandare a capo, come nel seguente codice:

\begin{figure}[posizione] \centering
\subfigure[caption sottofigura 1]{
           \includegraphics[opzioni] {subfigure1.eps} \label{label della sottofigura 1}
                                                         }   \\
\subfigure[caption sottofigura 1]{
           \includegraphics[opzioni] {subfigure1.eps} \label{label della sottofigura 1}
                                                         } \label{label dell'intera figura}
\caption{caption dell'intera figura}
\end{figure}