如何让标题居中而不让图像居中?

如何让标题居中而不让图像居中?

这是我的代码-

\documentclass[12pt]{book}
\usepackage{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{physics}
\usepackage{geometry}
\geometry{papersize={23cm,28cm}, right=9.3cm, left=3cm, top=2.5cm, bottom=3cm, marginparwidth=4.8cm, marginparsep=1.5cm, headheight=0cm}

\begin{document}
\marginpar{
\begin{figure}[H]
    \includegraphics[scale=0.65]{MainMatter/Organic chemistry/10.1: Fundamentals of Organic chemistry/Diagrams/Primary secondary tertiary halogenoalkanes 2.png}
    \caption{Primary, secondary, and tertiary halogenoalkanes}
    \label{Primary secondary tertiary halogenoalkanes}
\end{figure}}
Primary, secondary, and tertiary halogenoalkanes
Primary halogenoalkanes have one carbon atom attached to the $\ce{C}$ with the halogen atom. Secondary halogenoalkanes have two carbon atoms attached to the $\ce{C}$ with the halogen atom. Tertiary halogenoalkanes have two carbon atoms attached to the $\ce{C}$ with the halogen atom. Examples have been shown in figure \ref{Primary secondary tertiary halogenoalkanes} 
    \end{document}

我正在尝试修复这个标题,以便它不会溢出边注框 -在此处输入图片描述

有任何想法吗?

答案1

\documentclass[12pt]{book}
\usepackage{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{physics}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{geometry}
\geometry{papersize={23cm,28cm}, right=9.3cm, left=3cm, top=2.5cm, bottom=3cm, marginparwidth=4.8cm, marginparsep=1.5cm, headheight=0cm}

\begin{document}
    \marginpar{%
            \includegraphics[width=0.7\linewidth]{tiger}
            \captionof{figure}{Primary, secondary, and tertiary halogenoalkanes}
            \label{Primary secondary tertiary halogenoalkanes}}
    Primary, secondary, and tertiary halogenoalkanes
    Primary halogenoalkanes have one carbon atom attached to the $\ce{C}$ with the halogen atom. Secondary halogenoalkanes have two carbon atoms attached to the $\ce{C}$ with the halogen atom. Tertiary halogenoalkanes have two carbon atoms attached to the $\ce{C}$ with the halogen atom. Examples have been shown in figure \ref{Primary secondary tertiary halogenoalkanes} 
\end{document}

在此处输入图片描述

相关内容