推荐

推荐

半年前,以下代码

\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

重新修补

相关内容