캡션 명령과 결합된 KOMA-Script의 addmargin 환경

캡션 명령과 결합된 KOMA-Script의 addmargin 환경

KOMA-Script의 addmargin 환경(한 쪽 문서만 해당)을 사용하여 때로는 2/3 텍스트 영역과 1/3 여백으로 나누어진 문서의 전체 너비를 사용하여 내용을 작성하고 싶습니다.

이것은 작동합니다... 캡션 명령이 내가 원하는 대로 전체 너비를 차지하지 않는다는 것을 깨달을 때까지 다음을 참조하십시오(내 현재 코드(내 생각에 필요한 부분만)).

\documentclass[fontsize=12pt,twoside=false,paper=a4,DIV=15,BCOR=0mm,twocolumn=false,footinclude=true,headinclude=true,mpinclude=false]{scrreprt}% KOMAScript
\AfterCalculatingTypearea{%
    %% Margin
    \addtolength{\evensidemargin}{-\marginparwidth}%
    \addtolength{\textwidth}{\marginparwidth}%
    \setlength{\marginparwidth}{.333\textwidth}%
    \addtolength{\textwidth}{-\marginparwidth}%
    \addtolength{\evensidemargin}{\marginparwidth}%
}\recalctypearea%


\newlength{\overhang}%
\setlength{\overhang}{\marginparwidth}%
\addtolength{\overhang}{\marginparsep}%
\newenvironment{fullwidth}{%
    \begin{addmargin}[0em]{-\overhang}%
}{%
    \end{addmargin}%
}%


\usepackage{graphics}
\usepackage{graphicx}
\usepackage{caption}


\usepackage{float}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
    %% Works as intended
    \lipsum[1]
    \begin{fullwidth}
        \lipsum[1]
    \end{fullwidth}
    %% Problem with caption
    \newpage
    \begin{figure}[H]\centering
        \includegraphics[width=0.5\linewidth]{example-image-a}
        \caption{This caption is centered as it should be. \lipsum[1]}
    \end{figure}
    \begin{figure}[H]
        \begin{fullwidth}\centering
            \includegraphics[width=0.5\linewidth]{example-image-a}
            \caption{The image is centered, but the caption is NOT ugh... \lipsum[1]}
        \end{fullwidth}
    \end{figure}
\end{document}

출력은 다음과 같습니다여기에 이미지 설명을 입력하세요여기에 이미지 설명을 입력하세요여기에 이미지 설명을 입력하세요 누군가 이 문제를 해결하는 방법을 나에게 설명해 줄 수 있습니까? 캡션이 전체 너비를 이미지로 사용하기를 원합니다. 가능하다면 addmargin 환경에서 가능합니다. 이미 내 문서에서 매우 자주 사용하고 있기 때문입니다. :디

답변1

addmargin입니다 trivlist. AFAIK, 변경 \linewidth되지만 . 그러나 너비는 이것에 달려 있는 것 같습니다. 예를 들어 다음을 사용하십시오.\textwidth\hsize\caption

\documentclass[fontsize=12pt,twoside=false,paper=a4,DIV=15,BCOR=0mm,twocolumn=false,footinclude=true,headinclude=true,mpinclude=false]{scrreprt}% KOMAScript
\AfterCalculatingTypearea{%
    %% Margin
    \addtolength{\evensidemargin}{-\marginparwidth}%
    \addtolength{\textwidth}{\marginparwidth}%
    \setlength{\marginparwidth}{.333\textwidth}%
    \addtolength{\textwidth}{-\marginparwidth}%
    \addtolength{\evensidemargin}{\marginparwidth}%
}\recalctypearea%


\newlength{\overhang}%
\setlength{\overhang}{\marginparwidth}%
\addtolength{\overhang}{\marginparsep}%
\newenvironment{fullwidth}{%
  \begin{addmargin}[0em]{-\overhang}%
    \textwidth\linewidth\hsize\linewidth% added
}{%
    \end{addmargin}%
}%


\usepackage{graphics}
\usepackage{graphicx}
\usepackage{caption}


\usepackage{float}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
    %% Works as intended
    \lipsum[1]
    \begin{fullwidth}
        \lipsum[1]
    \end{fullwidth}
    %% Problem with caption
    \newpage
    \begin{figure}[H]\centering
        \includegraphics[width=0.5\linewidth]{example-image-a}
        \caption{This caption is centered as it should be. \lipsum[1]}
    \end{figure}
    \begin{figure}[H]
        \begin{fullwidth}\centering
            \includegraphics[width=0.5\linewidth]{example-image-a}
            \caption{The image is centered, but the caption is NOT ugh... \lipsum[1]}
        \end{fullwidth}
    \end{figure}
\end{document}

캡션에 추가 여백의 전체 너비를 사용합니다.

관련 정보