0

Want to include a graphic in the margin. Without \centering the graphic is to the left and the caption is shifted to the right and not even fully visible. When \centering is included the graphic is shifted far right where the caption is glued. How do I work around this?

\leavevmode\marginpar{
\begin{figure}[H]
%\centering
\includegraphics[scale=0.1]{ThiSulfat2D.png}
\caption{Thiosulfat, \ch{(S2O^{2-}3)}}
\label{fig4}
\end{figure}
}

My preamble

\documentclass[a4paper,10pt,fleqn,reqno]{article}
\usepackage{parskip}
\usepackage{geometry}
\geometry{
textwidth = 280pt,
marginparwidth=178pt,
marginparsep = 40pt,
lmargin = 90pt
}
\usepackage{multicol}
\setlength{\columnsep}{0.9cm}
\usepackage{supertabular}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{subfigure}

\usepackage{float}
\usepackage[swedish]{babel}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black,
    pdfborder = {0 0 0}
}
\usepackage{enumitem}
\usepackage{verbatimbox}
\usepackage{fancyvrb}
\usepackage{graphicx}   
\usepackage{lipsum}  
\usepackage[leqno]{amsmath}
\usepackage{listings} 
\usepackage{tikz}
\usepackage{cancel}
\usepackage{steinmetz}
\newcommand*\mycirc[1]{%
\begin{tikzpicture}[baseline={(0,-0.1)}]
\node[draw,circle,inner sep=1pt] {#1};
\end{tikzpicture}}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{
  font=small,
  labelfont=bf,
  tableposition=top
}
\usepackage{chemfig}
\usepackage{chemformula}
%\usepackage{chemmacros}
%\chemsetup{modules=all}
\usepackage{elements}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{marginnote}
\usepackage{layout}

3
  • 2
    As always on the site. please provide a full but minimal example others can copy and test as is. Here we have no idea what class and preamble you're using.
    – daleif
    Commented Oct 3, 2022 at 17:31
  • @daleif Added the preamble. Sorry. Commented Oct 3, 2022 at 19:15
  • 1
    Your image is probably too wide and is leaking out of the right margin. You should be getting a wanring about overfull \hbox. Commented Oct 4, 2022 at 3:36

1 Answer 1

1

It is not entirely clear what is your problem. Maybe the following MWE gives what looking for:

\documentclass[a4paper,10pt,fleqn,reqno]{article}
\usepackage[textwidth = 280pt,
            marginparwidth=178pt,
            marginparsep = 40pt,
            lmargin = 90pt
            ]{geometry} 
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage{chemfig}
\usepackage{chemformula}

\usepackage{graphicx}
\usepackage[font=small,
            labelfont=bf,
            tableposition=top
            ]{caption}
\usepackage{lipsum}

\begin{document}

\leavevmode\marginpar{
\centering
\includegraphics[width=\linewidth]{example-image-duck}
\captionof{figure}{Thiosulfat, \ch{(S2O^{2-}3)}}
\label{fig4}
}
\lipsum[1-3]
\end{document}

(red lines indicate page layout)

enter image description here

1
  • Works beautifully! :-) Thanks! Commented Oct 3, 2022 at 19:48

You must log in to answer this question.

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