Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I just started using mhchem and am having problems with captions. Subscripts from mchem overlap with superscripts. I can think of two possible solutions (and trivially not using mchem in captions):

  1. Adjust line spacing for a caption
  2. Change the position of mchem's subscripts when in captions

I am not sure how to do either and which one is best?

Here is a demo of the issue:

Here is the code to generate the example:

\documentclass[english,letterpaper]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[cmex10]{amsmath}
\usepackage[version=3]{mhchem}
\usepackage{microtype}
\interdisplaylinepenalty=2500

\begin{document}

\title{Caption Line Spacing}

\maketitle

\begin{abstract}
  I am having a problem with line spacing and subscript locations
  inside of captions when using mhchem. This is a demonstration of this
  effect.
\end{abstract}

\section{Caption Problem}
\label{sec:caption-problem}

Fig.~\ref{fig:demo} shows the problem with line spacing and mhchem
inside of captions. Occasionally text may overlap. Two possible
solutions are to (a) increase the line spacing (b) adjust subscript
position within mhchem.

\begin{figure}[h!]
\centering
\caption{Display of In\_\{0.53\}Ga\_\{0.47\}As using hbox and math
   mode: $\hbox{In}_{0.53}\hbox{Ga}_{0.47}\hbox{As}${}; mhchem in text
   environment: \ce{In_{0.53}Ga_{0.47}As}; mhchem in math environment:
   $\ce{In_{0.53}Ga_{0.47}As}${}. Super-scripted items:
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${}. Subscripts and superscripts for hbox and math:
   $\hbox{NMe}_4^+\hbox{Cl}^-${}; mhchem \ce{NMe4+Cl-}}
\label{fig:demo}
\end{figure}
\end{document}

(I am using pdfLaTeX and TeXLive2012)

share|improve this question
    
Welcome to TeX.sx! –  Kurt Feb 26 '13 at 5:59
    
You could insert a strut manually to move the respective lines apart from one another. One would assume that this is feasible since your captions will not all have similar requirements and layouts. –  Werner Feb 26 '13 at 6:09
1  
One option is to load caption and setspace packages then inside your figure environment, write \captionsetup{font={small,stretch=1}, strut=on} if that is the only caption that needs resolving. Otherwise, you can set it globally in your preamble. Well, small option is just a suggestion. –  hpesoj626 Feb 26 '13 at 6:17

1 Answer 1

up vote 1 down vote accepted

I might be missing something, but here is one way to do it.

Output

enter image description here

Explanation

  • You can load caption and setspace packages in your preamble. Then inside your figure environment, write \captionsetup{font={small,stretch=1}} to make the effect of the \captionsetup local. (This will however make the caption of that particular figure unlike your other captions in terms of line spacing but something has to give in order to achieve what you want.) I have suggested small value to font key but it is your call, of course. You can also play with values for stretch to achieve the effect that you want.

  • Will you be using other fonts in your document? If not, then there is no sense enclosing wrapping \ce in a math environment in your MWE unless I am missing something in your actual use case.

Code

Here is a full MWE that produced the output earlier.

\documentclass[english,letterpaper]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage[cmex10]{amsmath}
\usepackage[version=3]{mhchem}
\usepackage{caption}
\usepackage{setspace}
\interdisplaylinepenalty=2500

\begin{document}

\title{Caption Line Spacing}

\maketitle

\begin{abstract}
  I am having a problem with line spacing and subscript locations
  inside of captions when using mhchem. This is a demonstration of this
  effect.
\end{abstract}

\section{Caption Problem}
\label{sec:caption-problem}

Fig.~\ref{fig:demo} shows the problem with line spacing and mhchem
inside of captions. Occasionally text may overlap. Two possible
solutions are to (a) increase the line spacing (b) adjust subscript
position within mhchem.

\begin{figure}[h!]
\captionsetup{font={small,stretch=1.1}}
\centering
\caption{Display of In\_\{0.53\}Ga\_\{0.47\}As using hbox and math
   mode: $\hbox{In}_{0.53}\hbox{Ga}_{0.47}\hbox{As}${}; mhchem in text
   environment: \ce{In_{0.53}Ga_{0.47}As}; mhchem in math environment:
   \ce{In_{0.53}Ga_{0.47}As}. Super-scripted items:
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${} $1^{123}${} $1^{123}${} $1^{123}${}
   $1^{123}${}. Subscripts and superscripts for hbox and math:
   $\hbox{NMe}_4^+\hbox{Cl}^-${}; mhchem \ce{NMe4+Cl-}}
\label{fig:demo}
\end{figure}
\end{document}
share|improve this answer
    
This is the best way to go, aside from figuring out how to correct mhchem. I guess I did not really consider it because the caption package is supposed to conflict with the IEEEtran class. Thanks! –  Alex Grede Feb 27 '13 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.