Graphics, Figures & Tablesvectors in captions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
KMnO4aq
Posts: 7
Joined: Fri Jan 17, 2014 12:37 am

vectors in captions

Post by KMnO4aq »

Hello! I am pretty new to latex, and very new to this board, so please bare with me. I am writing my thesis, and I am having a problem with a specific caption in which there are vectors. Here is my main file:

Code: Select all

\documentclass[12pt]{report}
\usepackage{urcsthesisLK}
\usepackage[super,sort&compress]{natbib}
\usepackage{chapterbib}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{wrapfig}
\usepackage{esvect}

\begin{document}

\include{Thesis_opening}
\tableofcontents
\listoftables
\listoffigures

\include{Thesis_chapter1}
\include{Thesis_chapter2}
\include{Thesis_chapter3}

\end{document}
As you can see I have several chapters included. The caption issue is in chapter 1.

Code: Select all

\begin{figure}
\begin{center}
\includegraphics[scale=0.45]{SWNTnm.jpg} 
\caption{All SWNTs are defined by the parameters n and m. These parameters are defined as the magnitude of the chiral vector, \vec{C$_h$}, along the vectors \vec{a$_1$} and \vec{a$_2$} where m is the magnitude along \vec{a$_1$} and n is the magnitude along \vec{a$_2$}. \label{fig:SWNTnm} }
\end{center}
\end{figure}
The problem I am getting is hard to explain. The caption breaks. I have taken a screen shot.
broken_caption.jpg
broken_caption.jpg (171.63 KiB) Viewed 6588 times
Interestingly, in my list of figures, the caption is written correctly, but the caption extends past defined margins.

Please let me know what other information you will need from me. I am sorry if I have not included something obviously important.

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vectors in captions

Post by Johannes_B »

Hi, there were some problems concerning math mode. Please be aware that a construct like \vec{a_2} should be typeset in math mode completely. Have a look at the working example below.

Code: Select all

\documentclass[12pt]{report}

\usepackage[demo]{graphicx}
\usepackage{caption}

\begin{document}

\begin{figure}
\centering %better, 
%the environment places some additional white space
\includegraphics[scale=0.45]{SWNTnm.jpg}
\caption{All SWNTs are defined by the parameters 
$n$ and $m$.% if m and n are parameters, 
%they should also be typeset in math mode
These parameters are defined as the magnitude of the chiral vector, $\vec{C_h}$, along the vectors $\vec{a_1}$ and $\vec{a_2}$ where m is the magnitude along $\vec{a_1}$ and n is the magnitude along $\vec{a_2}$. \label{fig:SWNTnm} }
\end{figure}

\[\vec{C_h} \quad \vv{C_h}
\]

\end{document}
You can see the output by just clicking on Open in writelatex. Btw: Such a small example is called a minimal working example. That way i can be sure, that you and I are seeing the same and have the same basis to tackle any problems.

Best regards
Johannes
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
KMnO4aq
Posts: 7
Joined: Fri Jan 17, 2014 12:37 am

Re: vectors in captions

Post by KMnO4aq »

Thank you very much! It worked like a charm!

In general, is \centering to \begin{center} and \end{center} preferred when working in a figure or equation environment?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

vectors in captions

Post by Johannes_B »

Since it does not apply white space it is preferred by most people. Equations are centered by default (in most cases). Do you set the global option fleqn flushing all equations to the left?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
KMnO4aq
Posts: 7
Joined: Fri Jan 17, 2014 12:37 am

Re: vectors in captions

Post by KMnO4aq »

I did not, but I also did not know equations center by default. Told ya I am new to this. Thanks!
Post Reply