2

I have two figures next to one another and I want to centre my Figure caption, but completely, i.e. to include Figure x.x: in centering.

This is the code I'm using:

\begin{figure}[!tbph]
    \centering
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[scale=0.2]{images/pie_chart_mobile.png}
        \caption{Frequency of playing mobile video games}
        \label{fig:pie_chart_mobile}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[scale=0.2]{images/pie_chart_multiplayer.png}
        \caption{Preference regarding multiplayer games}
        \label{fig:pie_chart_multiplayer}
    \end{minipage}
\end{figure}

And this is what I get:

enter image description here

What I actually want to have is this:

enter image description here

I tried the justification=centering on the caption package, didn't help. Any ideas?

EDIT: MWE:

\RequirePackage[l2tabu,orthodox]{nag}

\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided

\PassOptionsToPackage{table,svgnames,dvipsnames}{xcolor}

\usepackage[%
  backend=biber,
  url=false,
  style=alphabetic,
  maxnames=4,
  minnames=3,
  maxbibnames=99,
  firstinits,
  uniquename=init]{biblatex} % TODO: adapt bibliography style
\usepackage[demo]{graphicx}
\usepackage{caption}

\captionsetup{justification=centering}

\begin{document}

\begin{figure}[!tbph]
    \centering
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[scale=0.2]{images/pie_chart_mobile.png}
        \caption{Frequency of playing mobile video games}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[scale=0.2]{images/pie_chart_multiplayer.png}
        \caption{Preference regarding multiplayer games}
    \end{minipage}
\end{figure}

\end{document}

Result:

enter image description here

5
  • From the images it seems as if you are using the option format=hang of the caption package, in addition to the justification=centering option. Remove the format=hang, and you should get the desired output.
    – sodd
    Commented Aug 21, 2015 at 11:52
  • I am not using this option, or any other option of the caption package. As I already wrote, I tried justification=centering, but it did not help, which means I'm probably somehow overwriting it, but I do not know how. So any ideas on that?
    – Banana
    Commented Aug 21, 2015 at 11:56
  • Edited the question.
    – Banana
    Commented Aug 21, 2015 at 11:59
  • 1
    @Banana a more useful edit would have made a complete document that showed the problem, with all packages removed that were not needed in the example. Commented Aug 21, 2015 at 12:01
  • Done as instructed :)
    – Banana
    Commented Aug 21, 2015 at 12:08

2 Answers 2

4

You have to set the caption indent to 0pt and the format to \centering as in the following in KOMA-Script:

\setcapindent{0pt}
\addtokomafont{caption}{\centering}

Thus, the following should work:

\RequirePackage[l2tabu,orthodox]{nag}

\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided

\PassOptionsToPackage{table,svgnames,dvipsnames}{xcolor}

\usepackage[%
  backend=biber,
  url=false,
  style=alphabetic,
  maxnames=4,
  minnames=3,
  maxbibnames=99,
  firstinits,
  uniquename=init]{biblatex} % TODO: adapt bibliography style
\usepackage[demo]{graphicx}
\usepackage{caption}

% The fix:
\setcapindent{0pt}
\addtokomafont{caption}{\centering}

\begin{document}
\begin{figure}
    \centering
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
        \caption{Frequency of playing mobile video games}
        \label{fig:pie_chart_mobile}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
        \caption{Preference regarding multiplayer games}
        \label{fig:pie_chart_multiplayer}
    \end{minipage}
\end{figure}
\end{document}

Output

0
1

Package caption

Package caption with option justification=centering helps usually:

\documentclass{article}
\usepackage[demo]{graphicx}% demo only because of missing images
\usepackage{caption}
\captionsetup{justification=centering}

\begin{document}
\begin{figure}[!tbph]
    \centering
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
        \caption{Frequency of playing mobile video games}
        \label{fig:pie_chart_mobile}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
        \caption{Preference regarding multiplayer games}
        \label{fig:pie_chart_multiplayer}
    \end{minipage}
\end{figure}
\end{document}

Result

Class KOMA-Script

See answer of nordev.

Class memoir

Class memoir provides \captionstyle:

\documentclass{memoir}
\usepackage[demo]{graphicx}% demo only because of missing images
\captionstyle{\centering}

\begin{document}
\begin{figure}[!tbph]
    \centering
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_mobile.png}
        \caption{Frequency of playing mobile video games}
        \label{fig:pie_chart_mobile}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.4\textwidth}
        \includegraphics[width=\linewidth]{images/pie_chart_multiplayer.png}
        \caption{Preference regarding multiplayer games}
        \label{fig:pie_chart_multiplayer}
    \end{minipage}
\end{figure}
\end{document}

Result

3
  • As I already wrote, I tried justification=centering, but it did not help, which means I'm probably somehow overwriting it, but I do not know how. So any ideas on that?
    – Banana
    Commented Aug 21, 2015 at 11:56
  • @Banana make a complete document as Heiko has done here that shows the captions not centred, then someone can easily tell you why it is not working. Commented Aug 21, 2015 at 11:59
  • Done as instructed :)
    – Banana
    Commented Aug 21, 2015 at 12:08

You must log in to answer this question.

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