标题调整

标题调整

我该如何调整章节标题,使最后一行以红色框结尾?有没有办法移动整个章节标题,使“章节”一词与正文一起调整,即使“章节”字母的上侧与下面的正文调整?

\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}

% 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}
}
\makeatother
%------------------------------------------

\begin{document}


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

例子

答案1

一个选项修补\@@makechapterhead

\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}

在此处输入图片描述

答案2

使用 KOMA-Script 版本 3.19a 或更新版本,您可以重新定义\chapterlinesformat

\documentclass[
  fontsize=12pt,
  a4paper,
  parskip=half,
  ngerman,
  headinclude=true,
  footinclude=false,
  captions=tableheading,
  numbers=noenddot,
  headings=big
]{scrreprt}[2015/10/03]

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{blindtext}

%------------------------------------------
\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}}
  \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
  \hspace*{1.5ex}
}
\newcommand\feline@chm[1][4cm]{%
  \sbox\feline@chapter{\feline@chapter@marker[#1]}%
  \usebox\feline@chapter%
}   
\renewcommand*{\chapterformat}{\feline@chm[2.5cm]}
\renewcommand\chapterlinesformat[3]{%
    #2\parbox[b]{\dimexpr\linewidth-\wd\feline@chapter\relax}{\raggedchapter#3}%
}
\makeatother
%------------------------------------------

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

在此处输入图片描述

相关内容