2

I googled quite extensively the last few days but didn't find a solution to this problem:

I have a document with side captions for images and tables. It looks great, when the picture's width is set to \textwidth.

Looks good.

However, when I change it to a smaller width, the caption moves with the picture towards the center of the page. So the image should be centered horizontally in the text and the side caption should stay in the margin beside the text.

Here's how it currently looks: enter image description here

And that's how it should look: enter image description here

When I try centering the image I get an error. If someone knows a solution that'd be great.

Here my code:

\documentclass[10pt,twoside,a4paper,fleqn]{report}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}

% Page layout_____________________________________________________________________
\usepackage[twoside]{geometry} 
\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=130mm,marginparsep=8.2mm,marginparwidth=33mm,textheight=54\baselineskip,headheight=\baselineskip}


% Graphics________________________________________________________________________
\usepackage{graphicx}

% Captions at the side of the page
\usepackage[wide]{sidecap}
\usepackage[font=footnotesize,format=plain,labelfont={bf,sf},textfont={it},width=10pt]{caption}


% Begin document__________________________________________________________________
\begin{document}

\chapter{This Chapter}
\blindtext

\begin{SCfigure}[\sidecaptionrelwidth][h!]
  \includegraphics[width=0.7\textwidth]{img/avalanche_triangle.png}
  \caption{Avalanche Triangle after xy. This shows blablabla add some more information here.}
  \label{avalanche}
\end{SCfigure}

\blindtext

\begin{SCfigure}[\sidecaptionrelwidth][h!]
%\begin{center} % This throws an error!
  \includegraphics[width=\textwidth]{img/avalanche_triangle.png}
  \caption{Avalanche Triangle after xy. This shows blablabla add some more information here.}
  \label{avalanche}
%\end{center}
\end{SCfigure}

\blindtext

\end{document}

Thanks a lot for your help!

0

You can use a parbox to have your desired result:

\documentclass[10pt,twoside,a4paper,fleqn]{report}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}

% Page layout_____________________________________________________________________
\usepackage[twoside]{geometry} 
\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=130mm,marginparsep=8.2mm,marginparwidth=33mm,textheight=54\baselineskip,headheight=\baselineskip}


% Graphics________________________________________________________________________
\usepackage{graphicx}

% Captions at the side of the page
\usepackage[wide]{sidecap}
\usepackage[font=footnotesize,format=plain,labelfont={bf,sf},textfont={it},width=10pt]{caption}


% Begin document__________________________________________________________________
\begin{document}

\chapter{This Chapter}
\blindtext

\begin{SCfigure}[\sidecaptionrelwidth][ht!]
  \parbox{\textwidth}{\centering\includegraphics[width=0.7\textwidth]{example-image-a}}
  \caption{Avalanche Triangle after xy. This shows blablabla add some more information here.}
  \label{avalanche}
\end{SCfigure}

\blindtext

\begin{SCfigure}[\sidecaptionrelwidth][ht!]
%\begin{center} % This throws an error!
  \includegraphics[width=\textwidth]{example-image-a}
  \caption{Avalanche Triangle after xy. This shows blablabla add some more information here.}
  \label{avalanche2}
%\end{center}
\end{SCfigure}

\blindtext

\end{document}

Output:

enter image description here

  • Thanks a lot! That worked like a charm. I've been trying to do this the whole week. Made my week! – Chris Mar 29 '18 at 10:50
  • Welcome... Have a nice day – koleygr Mar 29 '18 at 10:56

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.