KOMA 章节编号在页边距对齐

KOMA 章节编号在页边距对齐

我已设法将章节和节号放在页边距中。但是,我无法正确对齐它们,使它们与相应标题的距离相同。

在此处输入图片描述

梅威瑟:

\documentclass[10pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[osf]{newpxtext}
    \linespread{1.05}
\usepackage[left=32.5mm, right=25mm, top=25mm, bottom=20mm, marginparsep=3mm]{geometry}

\usepackage[headsepline]{scrlayer-scrpage}

\renewcommand\raggedchapter{\raggedleft}

\renewcommand*{\chapterformat}{%
  \rlap{\hskip\marginparsep\fontsize{80}{80}\fontfamily{pplx}\selectfont\thechapter}}

\makeatletter
\renewcommand\chapterlinesformat[3]{%
  \ifstr{#1}{chapter}
    {\hfill#2\makebox[0pt][r]{\parbox[b]{\textwidth}{\raggedchapter#3}}\par\rule    {\textwidth}{.4pt}}
    {\@hangfrom{#2}{#3}}
}
\makeatother

\setkomafont{chapter}{\huge\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}
\setkomafont{section}{\Large\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}

\providecommand{\Ifthispageodd}{\ifthispageodd}
\renewcommand*{\raggedsection}{\Ifthispageodd{\raggedleft}{\raggedleft}}
\renewcommand*{\sectionlinesformat}[4]{#4\makebox[0pt][l]{\hskip\marginparsep #3}}


\begin{document}


\chapter*{test}

\chapter{test}

\section{test}

\end{document}

相关内容