1

Refer to my mwe, the marginfigure works just fine. All labels are left align.

\documentclass[twoside]{scrbook}
\usepackage{xcolor,graphicx,kantlipsum,multicol}
\usepackage[papersize={21cm,23cm},top=1.8cm, bottom=2cm, outer=7cm, inner=2cm, heightrounded, marginparwidth=5.0cm, marginparsep=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{calc}
\usepackage{etoolbox}
\usepackage{sidenotes}
\usepackage{marginnote}
\usepackage{xparse}
\usepackage{l3keys2e}
\usepackage{changepage}
%\usepackage{keyfloat}
\usepackage{caption,subcaption}
%\captionsetup[subfigure]{
%   justification=centering,
%   labelfont={normalsize},
%   font={normalsize},
%}

%==========================================
\begin{document}
    \chapter{Chapter 1}
    \section{Section 1}
    \begin{marginfigure}[0cm]
        \begin{subfigure}{\marginparwidth}
            \includegraphics[width=\marginparwidth]{example-image-a.jpg}%
            \subcaption{A}\label{example-image-a.jpg}%
        \end{subfigure} 
        \begin{subfigure}{\linewidth}
            \includegraphics[width=\linewidth]{example-image-b.jpg}%
            \subcaption{B}\label{example-image-b.jpg}%
        \end{subfigure}     
        \begin{subfigure}{\linewidth}
            \includegraphics[width=\linewidth]{example-image-c.jpg}%
            \subcaption{C}\label{example-image-c.jpg}%
        \end{subfigure}
        %       \captionsetup{font=Large,justification=centering}
        \caption{xxx}
    \end{marginfigure}
\end{document}

leftaligned caption enter image description here enter image description here

When I want them to be at the center, I uncommented \captionsetup, the subsfigure a, b, and c are aligned at the center but the "Figure 1.1: xxx" was not. I have to add \captionsetup before \end{marginfigure} to make that happened. I want to do that globally instead of locally. How can I do that?.

2

In order to globally center the marginfigure's caption horizontally, you can use \DeclareCaptionStyle{marginfigure} as shown in the following MWE. The declaration of the font size originates in the definition in the sidenotes package.

\documentclass[twoside]{scrbook}
\usepackage{graphicx}
\usepackage[papersize={21cm,23cm},top=1.8cm, bottom=2cm, outer=7cm, inner=2cm, heightrounded, marginparwidth=5.0cm, marginparsep=0.5cm]{geometry}
\usepackage{sidenotes}
\usepackage{caption,subcaption}
\captionsetup[subfigure]{
   justification=centering,
   labelfont={normalsize},
   font={normalsize},
}
\DeclareCaptionStyle{marginfigure}{font=footnotesize,justification=centering}

%==========================================
\begin{document}
    \chapter{Chapter 1}
    \section{Section 1}
    \begin{marginfigure}[0cm]
        \begin{subfigure}{\marginparwidth}
            \includegraphics[width=\marginparwidth]{example-image-a.jpg}%
            \subcaption{A}\label{example-image-a.jpg}%
        \end{subfigure} 
        \begin{subfigure}{\linewidth}
            \includegraphics[width=\linewidth]{example-image-b.jpg}%
            \subcaption{B}\label{example-image-b.jpg}%
        \end{subfigure}     
        \begin{subfigure}{\linewidth}
            \includegraphics[width=\linewidth]{example-image-c.jpg}%
            \subcaption{C}\label{example-image-c.jpg}%
        \end{subfigure}
        \caption{xxx}
    \end{marginfigure}
\end{document}

enter image description here

  • where is defined marginfigure? – Zarko Mar 29 '18 at 18:25
  • @Zarko: The marginfigure environment is defined in the sidenotes package. – leandriis Mar 29 '18 at 18:44
  • thank you very much! i'm not familiar with sidenotes ... – Zarko Mar 29 '18 at 18:50
  • @Zarko: You're welcome. Before seeing this question, I wasn't familiar with this package either. – leandriis Mar 29 '18 at 19:15
  • @leandriis: Thanks for your code. Which page can i find the definition of DeclareCaptionStyle?. I want to learn more about the other options. – kmmm Mar 30 '18 at 3:35

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.