左右边距中的章节编号

左右边距中的章节编号

我想将章​​节号移到右边距(有点像主题中classicthesis),但我尝试过的所有方法都只会导致错误,如果有人能看看就好了。我正在使用 MWE scrreprt,我无法移动到课堂memoir

平均能量损失

经典论题

\documentclass[
fontsize=12pt,
twoside,
a4paper,               
parskip=half,      
ngerman,
headings=big]
{scrreprt}

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

\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

% 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=-0pt%\eurom{A}
            \colorbox{white}{\color{black}$\eurom{\thechapter}$}}}%
%       \rotatebox{90}{%
%           \resizebox{%
%               \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
%           {!}{\scshape\so\@chapapp}}\hspace{.4mm}%Abstand zum Wort Kapitel
        \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[1.61cm] % Height of the colored box
            \hspace{0.3cm}%Abstand zur Colorbox
        }

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


\begin{document}

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

\end{document}

答案1

这是另一个建议

\documentclass[
fontsize=12pt,
twoside,
a4paper,
parskip=half,
ngerman,
headings=big,
open=right
]
{scrreprt}

\usepackage[english,german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{blindtext}
%\usepackage{showframe}

\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

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

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
        \colorbox{white}{\color{black}$\eurom\thechapter$}}}%
  \raisebox{\depth}{\usebox{\feline@chapter}}%
}
\renewcommand*{\chapterformat}{%
  \sbox\feline@chapter{\feline@chapter@marker[1.61cm]}%
  \makebox[0pt][l]{%
    \makebox[\dimexpr\textwidth+\marginparsep+\wd\feline@chapter\relax][r]{%
      \usebox\feline@chapter}}%
}
\makeatother

\preto\chapterheadendvskip{%
  \vspace*{-\parskip}%
  {\noindent\setlength\parfillskip{0pt plus 1fil}\rule{\textwidth}{.4pt}\par}%
}

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

open=right请注意,如果章节编号应该位于右边距,我会使用它。

结果:

在此处输入图片描述


更新作为以下评论的答案:

如果要使用\MakeUppercase章节标题,您可以重新定义\chapterlinesformat。请注意,以下示例至少需要 KOMA-Script 版本 3.19:

\documentclass[
fontsize=12pt,
twoside,
parskip=half,
ngerman,
headings=big,
open=right
]
{scrreprt}[2015/10/03]

\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{etoolbox}

\usepackage{blindtext}

\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
        \colorbox{white}{\color{black}$\eurom\thechapter$}}}%
  \raisebox{\depth}{\usebox{\feline@chapter}}%
}
\renewcommand*{\chapterformat}{%
  \sbox\feline@chapter{\feline@chapter@marker[1.61cm]}%
  \makebox[0pt][l]{%
    \makebox[\dimexpr\textwidth+\marginparsep+\wd\feline@chapter\relax][r]{%
      \usebox\feline@chapter}}%
}
\renewcommand\chapterlinesformat[3]{%
  \ifstr{#1}{chapter}
  {\@hangfrom{#2}{\MakeUppercase{#3}}}
  {\@hangfrom{#2}{#3}}%
}
\makeatother

\preto\chapterheadendvskip{%
  \vspace*{-\parskip}%
  {\noindent\setlength\parfillskip{0pt plus 1fil}\rule{\textwidth}{.4pt}\par}%
}

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

在此处输入图片描述

答案2

我认为我找到了一个很好的解决方案线

在此处输入图片描述

\documentclass[
fontsize=12pt,
twoside,
a4paper,               
parskip=half,      
ngerman,
headings=big]
{scrreprt}

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

\DeclareMathAlphabet\EuRoman{U}{eur}{m}{n}
\SetMathAlphabet\EuRoman{bold}{U}{eur}{b}{n}
\newcommand{\eurom}{\EuRoman}

% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\definecolor{gray}{gray}{0.55} 
\usepackage{soul}
\usepackage{pdfpages}
\usepackage{varwidth}
\usepackage[calcwidth,explicit]{titlesec}

%\makeatletter
%\newsavebox{\feline@chapter}
%\newcommand\feline@chapter@marker[1][4cm]{%
%   \sbox\feline@chapter{%
%       \resizebox{!}{#1}{\fboxsep=-0pt%\eurom{A}
%           \colorbox{white}{\color{black}$\eurom{\thechapter}$}}}%
%%      \rotatebox{90}{%
%%          \resizebox{%
%%              \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
%%          {!}{\scshape\so\@chapapp}}\hspace{.4mm}%Abstand zum Wort Kapitel
%       \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[1.61cm] % Height of the colored box
%           \hspace{0.3cm}%Abstand zur Colorbox
%       }
%       
%\patchcmd{\@@makechapterhead}
%{\usekomafont{chapter}{#1}}
%{\parbox[b]{\dimexpr\textwidth-4cm\relax}{\raggedright\usekomafont{chapter}{#1}}}
%{\typeout{great}}
%{\typeout{too bad}}
%\makeatother
%%------------------------------------------

\newsavebox\mybox

\newlength\mylen
\newlength\titlewd
\newlength\ftitlewd
\newlength\titleboxwd
\setlength\mylen{3pc}
\setlength\titleboxwd{\dimexpr\textwidth-\mylen\relax}
\setlength\ftitlewd{\titleboxwd}

\newcommand\chapfont{\LARGE\bfseries\raggedleft}

\titleformat{\chapter}[hang]
{\chapfont\filleft}
{}{0pc}
{%
    \begin{lrbox}{\mybox}%
        \begin{varwidth}[t]{\titleboxwd}%
            \chapfont#1%
        \end{varwidth}%
    \end{lrbox}%
    \settowidth\titlewd{\usebox\mybox}%
    \ifdim\titlewd<\titleboxwd%
    \global\setlength\ftitlewd{\titlewd}%
    \fi%
    \parbox[t]{\ftitlewd}{\usebox\mybox}%
    \makebox[0pt][l]{\parbox[b]{4pc}{\hfill\scalebox{3}{\textcolor{gray}{$\eurom{\thechapter}$}}}}%
}%\color{black}$\eurom{\thechapter}$
[\vskip-1.4ex{\makebox[0pt][l]{%
        \hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titleformat{name=\chapter,numberless}[hang]
{\chapfont\filleft}
{}{0pc}
{%
    \begin{lrbox}{\mybox}%
        \begin{varwidth}[t]{\titleboxwd}%
            \chapfont#1%
        \end{varwidth}%
    \end{lrbox}%
    \settowidth\titlewd{\usebox\mybox}%
    \ifdim\titlewd<\titleboxwd%
    \global\setlength\ftitlewd{\titlewd}%
    \fi%
    \parbox[t]{\ftitlewd}{\usebox\mybox}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
        \hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titlespacing*{\chapter}
{1\mylen}{50pt}{40pt}

\begin{document}

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

\end{document}

相关内容