# Fix sidecaption independent from image size

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.

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:

And that's how it should look:

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}

% 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!

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}

% 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:

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