추천

추천

반년 전에 다음 코드는

\documentclass[             fontsize=12pt,
% monochrome,
a4paper,               
parskip=half,      
ngerman,
headinclude=true,
footinclude=false,
captions=tableheading,
numbers=noenddot,
headings=big]
%chapterprefix=true]   % 
{scrreprt}

\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{blindtext}
\usepackage{etoolbox}

% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\usepackage{soul}
\usepackage{pdfpages}

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
    \sbox\feline@chapter{%
        \resizebox{!}{#1}{\fboxsep=1pt%
            \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
        }}%
        \rotatebox{90}{%
            \resizebox{%
                \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
            {!}{\scshape\so\@chapapp}}\quad%
        \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
    }
    \newcommand\feline@chm[1][4cm]{%
        \sbox\feline@chapter{\feline@chapter@marker[#1]}%
        \makebox[0pt][l]{% aka \rlap
            \makebox[1cm][r]{\usebox\feline@chapter}%
        }}   

        \renewcommand*{\chapterformat}{%
            \hspace{\leftmargin} \feline@chm[2.5cm] % Height of the colored box
            \hspace{2cm}
        }

        \patchcmd{\@@makechapterhead}
        {\size@chapter{#1}}
        {\size@chapter{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright#1}}}
        {}
        {}
        \makeatother
        %------------------------------------------

        \begin{document}


            \chapter{Lorem ipsum dolor sit amet, consectetuer adipiscing elit}
            \blindtext[2]
        \end{document}

이 문서를 만들었지 여기에 이미지 설명을 입력하세요만 더 이상 작동하지 않는 것 같습니다(PC를 포맷하고 Miktex와 Texstudio를 다시 설치했습니다). 이제 이 그림과 같습니다. 여기에 이미지 설명을 입력하세요 이전 출력을 다시 가져오려면 어떻게 해야 합니까?

답변1

추천

를 사용할 때 \patchcmd작업이 중단될 때를 대비해 마커를 넣는 것이 정말 중요합니다.

\patchcmd{\@@makechapterhead}
{\size@chapter{#1}}
{\size@chapter{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright#1}}}
{\typeout{great}}
{\typeout{too bad}}

이는 출력을 검사할 때 패치가 성공하지 못했음을 보여줍니다. (물론 일반적으로 위의 것보다 더 유익한 것을 사용해야 무엇이 잘못되었는지 알 수 있습니다. 그러나 이것은 단지 시연 목적일 뿐입니다.)

따라서 패치 중인 명령이 변경되어 패치가 더 이상 필요하지 않은 것 같습니다.

설명

해당 명령의 현재 정의는 다음과 같습니다.

\newcommand*{\@@makechapterhead}[1]{%
  \@tempskipa=\glueexpr \scr@chapter@sectionbeforeskip\relax
  \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
  \chapterheadstartvskip
  {%
    \setlength{\parindent}{\z@}\setlength{\parfillskip}{\fill}%
    \normalfont\sectfont\nobreak\nobreak\usekomafont{chapter}{}%
     \def\IfUseNumber{\ifnumbered{chapter}}%
    \if@chapterprefix
      \raggedchapter
      \let\IfUsePrefixLine\@firstoftwo
      \let\@tempa\@firstofone
    \else
      \let\IfUsePrefixLine\@secondoftwo
      \let\@tempa\@hangfrom
    \fi
    \@tempa{%
      \IfUseNumber{%
        \usekomafont{chapter}{%
          \IfUsePrefixLine{%
            {\usekomafont{chapterprefix}{%
                \chapterformat\chapterheadmidvskip
            }}%
          }{%
            \chapterformat
          }%
        }%
      }{}%
    }%
    {%
      \IfUsePrefixLine{}{\raggedchapter}%
      \interlinepenalty \@M
      \usekomafont{chapter}{#1}\par
    }%
  }%
  \nobreak\par\nobreak
  \@tempskipa=\glueexpr \scr@chapter@sectionafterskip\relax
  \ifdim\@tempskipa<\z@\@tempskipa-\@tempskipa\fi
  \chapterheadendvskip
}

따라서 \size@chapter{#1}더 이상 사용되지 않으며 etoolbox패치할 항목을 찾을 수 없습니다.

반점

아마도 다음과 같은 것을 더 원할 것입니다.

\patchcmd{\@@makechapterhead}
{\usekomafont{chapter}{#1}}
{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright\usekomafont{chapter}{#1}}}
{\typeout{great}}
{\typeout{too bad}}
\makeatother

재패치됨

관련 정보