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!

domenica 27 settembre 2015

Costumized Environments for the Beginning of Section

I want to have some kind of "direction" at the beginning of a section or a chapter, where I state what I want to describe.
I decided to have two different things, one as the "title" of the "direction" and the other one a list of concepts to be covered each one in a different paragraph.
Let's divide the problem in two parts, the "title".

First I tried to write a simple newcommand
\newcommand{\dira}[1]{\textcolor{OrangeRed}{#1}\\}
 The breaking line at the end \\ is necessary as I want to remark it is a "title".
Also, I chose OrangeRed as color, and to be able to use it I loaded the package xcolor with the options usenames and dvipsnames.
 Then I thought, why don't I center it, since it is a title:
\newcommand{\dira}[1]{\begin{center}\textcolor{OrangeRed}{#1}\end{center}}
Note there is no \\ anymore. I am not sure I will leave this way or the left aligned version.

The second problem, is also not so complicated. I want to define a new environment:
\newenvironment{dirb}%
{\color{Aquamarine}\begin{itemize}}%
{\end{itemize}%
\color{black}}
This makes a listing environment all colored in Aquamarine.

The final problem would be to put them together, so to call only once the "dir" command/environment, instead of \dira and \begin{dirb}...\end{dirb} as it is now.
Quick trials are not successful, I will have to think harder to find a solution.

New post series

This post is only for an announcement
So, it has been a while I am not writing here, two years or so...
I should start again, and what's best than doing so, when starting to write my dissertation?
Also, my dissertation is in English, it's too much effort to change language to write in the blog ^^

martedì 16 aprile 2013

Linea su testo

Per creare del testo che abbia una linea sopra, e' necessario usare il pacchetto:
  •  \usepackage{ulem}
e il comando  \sout{Frase o parole}. Il risultato sara' del tipo:
Frase o parole
Per evitare alcuni problemi con questo pacchetto, riguardo ad altri stili di scrittura (grassetto o corsivo, per esempio) si consiglia di usare l'opzione normalem:
  •  \usepackage[normalem]{ulem}

Multirow e multicolumn

Utilizzando il pacchetto
  • multirow
e' possibile costruire tabelle unendo celle adiacenti o sotto(sovra)stanti come nel seguente esempio attraverso l'uso del comando multirow vengono unite due celle incolonnate:
\begin{table}[POSIZIONE]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Sample} & $MW$ & $\varepsilon_{260}$ & \multirow{2}{*}{$pH$} & $c$ & Peak & \multirow{2}{*}{$\frac{OD_{260}}{OD_{280}}$}\\ %\hline
& $[g/mol]$ & $[l/mol\cdot cm]$ & & $[\mu M]$ & [$nm$] & \\ \hline
\end{tabular}
\caption{CAPTION}
\label{LABEL}
\end{table}
Quest'altro esempio invece mostra specificamente l'uso di multicolumn:
\begin{table}[POSIZIONE]
\centering\begin{tabular}{|c|c|c|}
\hline
\multicolumn{3}{|c|}{Samples} \\ \hline
first base & second base & DNA \\ \hline
\end{tabular}
\caption{CAPTION}
\label{LABEL}
\end{table}

[POSIZIONE] e' l'usuale opzione per posizionare la figura nel documento:
  • ! da priorita', 
  • t significa top, metti la figura preferenzialmente in cima alla pagina, 
  • b bottom, mettila in fondo, 
  • h here, se riesci mettila proprio dove sta nel codice, 
  • p significa page tieni una pagina intera per questa figura.

martedì 4 dicembre 2012

Setbeamercolor

    \setbeamercolor{OPTION}{fg=COLOR,bg=COLOR}

    fg: foreground
    bg: background
     
    OPTIONS:
     
    abstract
    abstract title
    alerted text
    author
    author in head/foot
    author in sidebar
    background
    background canvas
    bibliography entry author
    bibliography entry location
    bibliography entry note
    bibliography entry title
    bibliography item
    block body
    block body alerted
    block body example
    block title
    block title alerted
    block title example
    button
    button border
    caption
    caption name
    date
    date in head/foot
    date in sidebar
    description item
    enumerate item
    enumerate subitem
    enumerate subsubitem
    example text
    fine separation line
    footline
    framesubtitle
    frametitle
    frametitle right
    headline
    institute
    institute in head/foot
    institute in sidebar
    item
    item projected
    itemize item
    itemize subitem
    itemize subsubitem
    itemize/enumerate body
    itemize/enumerate subbody
    itemize/enumerate subsubbody
    local structure
    logo
    lower separation line foot
    lower separation line head
    math text
    math text displayed
    math text inlined
    middle separation line foot
    middle separation line head
    mini frame
    navigation symbols
    navigation symbols dimmed
    normal text
    normal text in math text
    normal text in math text
    page number in head/foot
    palette primary
    palette quaternary
    palette secondary
    palette sidebar primary
    palette sidebar quaternary
    palette sidebar secondary
    palette sidebar tertiary
    palette tertiary
    part name
    part title
    qed symbol
    quotation
    quote
    section in head/foot
    section in sidebar
    section in sidebar shaded
    section in toc
    section in toc shaded
    section name
    section number projected
    section title
    separation line
    sidebar
    sidebar left
    sidebar right
    structure
    subitem
    subitem projected
    subsection in head/foot
    subsection in sidebar
    subsection in sidebar shaded
    subsection in toc
    subsection in toc shaded
    subsection name
    subsection number projected
    subsection title
    subsubitem
    subsubitem projected
    subsubsection in head/foot
    subsubsection in sidebar
    subsubsection in sidebar shaded
    subsubsection in toc
    subsubsection in toc shaded
    subsubsection number projected
    subtitle
    title
    title in head/foot
    title in sidebar
    titlegraphic
    titlelike
    upper separation line foot
    upper separation line head
    verse
     
     

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}