让标题浮动到边距

让标题浮动到边距

我搜索了很长时间才找到一个解决方案,让图形和/或表格的标题扩展到外部边距。我能够得到一个宽度为 的图形/表格textwidthmarginparwidth请参阅下面使用解决方案的 MWE在 stackexchange 上

编辑:感谢 Steven B. Segletes 找到了正确的问题,我能够\captionsetup{margin={0pt,-\marginparwidth}}使用caption-package 命令修复此问题。我也编辑了下面的代码。

\documentclass[%
    12pt,
    BCOR=15mm,
    captions=tableheading,
    DIV=current,
    ]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[demo]{graphicx}

\usepackage[
    top=30mm,
    bottom=40mm,
    inner=30mm,
    outer=55mm,
    marginparsep=5mm,
    marginparwidth=30mm,
    ]{geometry}

\usepackage[leqno, fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{booktabs}
\usepackage{array, tabularx}

\usepackage{ifoddpage}
\newlength\fullwidth\fullwidth=\textwidth \advance\fullwidth by \marginparwidth

\begin{document}

\begin{figure}
    \checkoddpage
    \edef\side{\ifoddpage l\else r\fi}
    \makebox[\textwidth][\side]{% 
        \includegraphics[width=\fullwidth]{figure}
    }%
    \captionsetup{margin={0pt,-\marginparwidth}}
    \caption{Long captiontext do get two lines, so I can see, if the caption expands into the margin.\label{fig:label}}
\end{figure}

\begin{table}[h]
    \captionsetup{margin={0pt,-\marginparwidth}}
    \caption{Instabile Isotope können unter Aussendung von Kernteilchen zerfallen. Dabei bilden sie neue Isotope.\label{tab:radiozerfall}}
    \checkoddpage
    \edef\side{\ifoddpage l\else r\fi}
    \makebox[\textwidth][\side]{% 
        \begin{tabularx}{1.01\fullwidth}{>{\kern-\tabcolsep}XXXXXX<{\kern-\tabcolsep}}
        \toprule
        Produkt       & \multicolumn{2}{c}{Strahlungs-} & \multicolumn{3}{c}{Eigenschaften der Strahlungsteilchen}  \\
                       & teilchen           & bezeichnung          & Kernladungs\-zahl & Nukleonen\-zahl & Durchdrin\-gung \\
        $^{A-4}_{Z-2}\text{E}$ & He-Kern            & $\alpha$-Strahlung   & $+2$              & 4               & gering          \\
        $^{A}_{Z+1}\text{E}$   & Elektron           & $\beta$-Strahlung    & $-1$              & 0               & mittel          \\
        unverändert            & Photon             & $\gamma$-Strahlung   & $\phantom{-}0$    & 0               & groß            \\ \bottomrule
        \end{tabularx}}
\end{table}

\end{document}

提前致谢。

答案1

caption这是使用包及其键的选项margin(我添加了该showframe选项geometry以便为页面布局提供视觉帮助;我还增加了\marginparsep图形、表格和标题的宽度,但这是可选的):

\documentclass[%
    12pt,
    BCOR=15mm,
    captions=tableheading,
    DIV=current,
    ]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[demo]{graphicx}

\usepackage[
showframe,
    top=30mm,
    bottom=40mm,
    inner=30mm,
    outer=55mm,
    marginparsep=5mm,
    marginparwidth=30mm,
    ]{geometry}

\usepackage[leqno, fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{booktabs}
\usepackage{array, tabularx}

\usepackage{ifoddpage}
\newlength\fullwidth\fullwidth=\textwidth \advance\fullwidth by \marginparwidth
\advance\fullwidth by \marginparsep
\usepackage{caption}

\newlength\extraWd
\setlength\extraWd{\dimexpr\marginparwidth+\marginparsep\relax}

\begin{document}

\begin{figure}
    \captionsetup{margin={0cm,-\extraWd}}
    \checkoddpage
    \edef\side{\ifoddpage l\else r\fi}
    \makebox[\textwidth][\side]{% 
        \includegraphics[width=\fullwidth]{figure}
    }%
    \caption{Long captiontext do get two lines, so I can see, if the caption expands into the margin.\label{fig:label}}
\end{figure}

\begin{table}[h]
    \captionsetup{margin={0cm,-\extraWd}}
    \caption{Instabile Isotope können unter Aussendung von Kernteilchen zerfallen. Dabei bilden sie neue Isotope.\label{tab:radiozerfall}}
    \checkoddpage
    \edef\side{\ifoddpage l\else r\fi}
    \makebox[\textwidth][\side]{% 
        \begin{tabularx}{1.01\fullwidth}{>{\kern-\tabcolsep}XXXXXX<{\kern-\tabcolsep}}
        \toprule
        Produkt       & \multicolumn{2}{c}{Strahlungs-} & \multicolumn{3}{c}{Eigenschaften der Strahlungsteilchen}  \\
                       & teilchen           & bezeichnung          & Kernladungs\-zahl & Nukleonen\-zahl & Durchdrin\-gung \\
        $^{A-4}_{Z-2}\text{E}$ & He-Kern            & $\alpha$-Strahlung   & $+2$              & 4               & gering          \\
        $^{A}_{Z+1}\text{E}$   & Elektron           & $\beta$-Strahlung    & $-1$              & 0               & mittel          \\
        unverändert            & Photon             & $\gamma$-Strahlung   & $\phantom{-}0$    & 0               & groß            \\ \bottomrule
        \end{tabularx}}
\end{table}

\end{document}

结果:

在此处输入图片描述

相关内容