我正在尝试在双面文档中以不同的方式勾勒章节标题。具体来说,我想使用 KOMA 脚本来实现。当在奇数页(右页)时,章节标题应在右侧勾勒,数字应显示在右侧页边距中;当在左侧时,文本应在左侧勾勒,数字显示在文本左侧。
我已经尝试适应这个问题满足我的需求,但没有成功。例如:当不编辑该答案并仅添加选项时twoside
,我得到:
我正在尝试适应这一点,并且仍然使用 KOMA 脚本。我的尝试如下:
\documentclass[twoside]{scrartcl}[2015/10/03]
\usepackage{showframe}
% my edit:
\renewcommand\sectionlinesformat[4]{%
\ifthispageodd{%
\raggedleft\makebox[0pt][r]{#4}#3}{%
\raggedright\makebox[0pt][r]{#3}{#4}}
}
\usepackage[headwidth=textwithmarginpar]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}
然而,问题 (a) 仍然存在(未改变),而问题 (b) 现在变成了:
答案1
\documentclass[twoside]{scrartcl}
%\providecommand*\Ifthispageodd{\ifthispageodd}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{showframe}
\renewcommand\sectionlinesformat[4]{%
\Ifthispageodd
{\raggedleft#4\makebox[0pt][l]{\enskip#3}}% <- changed
{\raggedright\makebox[0pt][r]{#3}#4}% <- comment space at line end
}
\usepackage[headwidth=textwithmarginpar]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}
如果章节编号应该位于marginpar
(边注区域):
\documentclass[twoside]{scrartcl}
%\providecommand*\Ifthispageodd{\ifthispageodd}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{showframe}
\renewcommand\sectionformat{\thesection\autodot}
\renewcommand\subsectionformat{\thesubsection\autodot}
\renewcommand\subsubsectionformat{\thesubsubsection\autodot}
\renewcommand\sectionlinesformat[4]{%
\Ifthispageodd
{\raggedleft#4\makebox[0pt][l]{\hspace{\marginparsep}#3}}
{\raggedright\makebox[0pt][r]{#3\hspace{\marginparsep}}#4}%
}
\usepackage[headwidth=textwithmarginpar]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}