1

I'm trying to split an image and its caption across two minipages, but the caption is running into the right margin of the page:

\documentclass[a4paper, 12pt]{article}

\usepackage{ifpdf}
\usepackage[latin1]{inputenc}
\usepackage[margin=2cm, left=2cm, top = 2cm, bottom=2cm]{geometry}
\usepackage{amsmath, mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epigraph}
\usepackage{wasysym}
\usepackage[none]{hyphenat}
\usepackage[super]{nth}
\usepackage{textcomp}
\usepackage[usenames]{xcolor}
\usepackage{hyperref}
\usepackage[authoryear]{natbib}
\usepackage{comment}
\usepackage{setspace}
\usepackage{float}
\usepackage{dcolumn}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multicol}
%\usepackage[symbol]{footnotemisc}

\usepackage{siunitx}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\let\oldFootnote\footnote
\newcommand\nextToken\relax

\renewcommand{\thefootnote}{\fnsymbol{footnote}} 
\renewcommand\footnote[1]{%
    \oldFootnote{#1}\futurelet\nextToken\isFootnote}

\newcommand\isFootnote{%
    \ifx\footnote\nextToken\textsuperscript{,}\fi}

\captionsetup{font={normalfont},labelfont=footnotesize, width=.6\textwidth}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\newcommand\cjaa{Chinese Journal of Astronomy \& Astrophysics}
\newcommand\pasp{Astronomical Society of the Pacific, Publications}
\newcommand\apj{The Astrophysical Journal}
\usepackage{setspace}
%\singlespacing
%\onehalfspacing
\doublespacing
%\setstretch{1.1}

\begin{document}
The original spectrum, taken by Green and Schmidt, is shown in Figure \ref{fig:3c273 spectrum}.\\
\begin{figure}[h!]
    \begin{minipage}[c]{0.5\textwidth}
        \includegraphics[width=0.9\textwidth]{"../3c273 spectrum"}
    \end{minipage}\hfill
    \begin{minipage}[c]{0.4\textwidth}
        \caption[3C 273 spectrum]{Spectrum of the quasar 3C 273. Comparison spectrum is H + He + Ne. Redshifted emission lines of H and O\textsc{iii} are indicated.} \label{fig:3c273 spectrum}
    \end{minipage}
\end{figure}
\\
Correcting for cosmological expansion yields a redshift for 3C 273 of 0.154, close to the

\end{document}

enter image description here

I've based the code on an answer from this question (the "direct and robust method"). I like this method for its simplicity, so I'd like to just adjust it slightly if possible.

How can I stop the caption from running into the margin? I've tried several different value of minipage and graphics width.

EDIT: put compilable code into the question.

1
  • Could you please post a complete compilable code?
    – Bernard
    Feb 21, 2019 at 20:28

1 Answer 1

0

You defined the caption width to be 0.6\textwidth outside the minipage.

\captionsetup{font={normalfont},labelfont=footnotesize, width=.6\textwidth}

If you remove the width definition (width=.6\textwidth) you will get the behavior you're looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .