5

In order to provide visual contrast, I have decided that I would like to have a certain section of a document I'm writing indented. To achieve this, I've simply been using the quote environment because that seems to be the simplest way of doing it.

The problem is that I would like to include some pictures in this subsection with captions. The problem is that if you use the \caption command, the caption is not indented:

enter image description here

It would seem trivial to correct this with a quick and dirty solution like the following:

\begin{figure}[!ht]\addtocounter{figure}{1}

  \begin{center}

    \includegraphics[width=10cm]{assets/fig001.png}

    \begin{quote}Figure \thefigure: Lorem ipsum dolor sit amet, consectetur
    adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
    magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
    ullamco laboris nisi ut aliquip ex ea commodo consequat.\end{quote}

  \end{center}

\end{figure}

Where I've simply called the quote environment again, within the figure environment. But, for some reason, if you do this, the indentations aren't quite right and the captions are still indented by a slightly lesser amount than the rest of the text, as you can see:

enter image description here

The above was produced using the following MWE (the lipsum package was not used because I found the paragraphs were too long to screenshot):

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[demo]{graphicx}

\begin{document}

  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  commodo consequat.

  \begin{quote}

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
    minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
    ex ea commodo consequat.

    \begin{figure}[!ht]\addtocounter{figure}{1}

      \begin{center}

        \includegraphics[width=10cm]{assets/fig001.png}

        \begin{quote}Figure \thefigure: Lorem ipsum dolor sit amet,
        consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
        labore et dolore magna aliqua. Ut enim ad minim veniam, quis
        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat.\end{quote}

      \end{center}

    \end{figure}

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat.

  \end{quote}

  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
  commodo consequat.

\end{document}
  • 2
    You probably want to look at the caption package. – egreg Apr 22 '14 at 22:15
  • Looks good, I'll have a read – Au101 Apr 22 '14 at 22:18
4

Within the default quote environment, the length \rightmargin is set to be the same as \leftmargin (from report.cls):

\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}

If you use the caption package you can force the width to be exactly (say) \dimexpr\linewidth-\rightmargin-\leftmargin giving you an output like

enter image description here

However, be careful, since floats may not end up where you put them in the text. With a float placement specifier of [tb] (instead of your [!ht]), the output resembles

enter image description here

which might not seem that ideal. Since you may not be interested in letting the image float, don't use a floating environment like figure, but rather a center environment with a manual \captionof{figure} (if you load caption or capt-of) set inside a fixed-width box of width \linewidth:

  \begin{center}

    \includegraphics[width=10cm]{assets/fig001.png}

    \begin{minipage}{\linewidth}
    \captionof{figure}{Lorem ipsum dolor sit amet,
    consectetur adipisicing elit, sed do eiusmod tempor incididunt ut
    labore et dolore magna aliqua. Ut enim ad minim veniam, quis
    nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat}
    \end{minipage}

  \end{center}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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