我正在使用\MakeUppercase
命令(来自\textcase
)(但也尝试过,\MakeTextUppercase
因为我认为问题可能是由章节号的数学环境引起的)和\addtokomafont{chapter}{...}
设置 Koma-script 报告类的命令。我的 MWE 基于以下内容线。不幸的是,添加\MakeUppercase
到\addtokomafont{chapter}{\normalsize\scshape}
不能与改变后的章节格式编译,但没有它可以编译,有人知道如何解决这个问题吗?
\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}
\usepackage{textcase}
\setkomafont{sectioning}{\rmfamily}
\setkomafont{caption}{\small}
\setkomafont{captionlabel}{\sffamily\bfseries\small}
\setkomafont{chapterentry}{\small\bfseries}
\setkomafont{chapter}{\normalsize}
\setkomafont{section}{\normalsize}
\setkomafont{subsection}{\normalsize}
\addtokomafont{chapter}{\normalsize\scshape}%%%%%%%%% \MakeUppercase
\addtokomafont{section}{\normalsize\scshape\MakeTextLowercase}
\addtokomafont{subsection}{\normalsize\itshape}
% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{fancyhdr}
\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
\sbox\feline@chapter{%
\resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
\colorbox{white}{\color{black}$\eurom\thechapter$}}}%!!!!!Error?
\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}%
{\setlength\parfillskip{0pt plus 1fil}\rule{\textwidth}{.4pt}\par}%
}
\begin{document}
\tableofcontents
\chapter{Lorem ipsum dolor sit amet, consectetuer}
\blindtext[2]
\section{Lorem ipsum dolor sit amet, consectetuer}
\end{document}
答案1
使用 KOMA-Script 3.19 或更新版本即可实现这一点。在 3.19 版本中引入了新命令\chapterlinesformat
和。它们在\sectionlinesformat
KOMA-Script 文档。
以下是使用这些命令的建议:
\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}
\usepackage{textcase}
\setkomafont{sectioning}{\rmfamily}
\setkomafont{caption}{\small}
\setkomafont{captionlabel}{\sffamily\bfseries\small}
\setkomafont{chapterentry}{\small\bfseries}
\setkomafont{chapter}{\normalsize}
\setkomafont{section}{\normalsize}
\setkomafont{subsection}{\normalsize}
\addtokomafont{chapter}{\normalsize\scshape}
\addtokomafont{section}{\normalsize\scshape}
\addtokomafont{subsection}{\normalsize\itshape}
% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\definecolor{nicered}{rgb}{.647,.129,.149}
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{fancyhdr}
\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
\sbox\feline@chapter{%
\resizebox{!}{#1}{\setlength{\fboxsep}{0pt}%
\colorbox{white}{\color{black}$\eurom\thechapter$}}}%!!!!!Error?
\raisebox{\depth}{\usebox{\feline@chapter}}%
}
\renewcommand\chapterformat{\sbox\feline@chapter{\feline@chapter@marker[1.61cm]}%
\makebox[0pt][l]{\hspace*{\marginparsep}\usebox\feline@chapter}}
\renewcommand\chapterlinesformat[3]{%
\parbox[t]{\textwidth}{\raggedchapter\MakeUppercase{#3}}%
#2%
\\\rule{\textwidth}{.4pt}
}
\renewcommand*{\sectionlinesformat}[4]{%
\@hangfrom{\hskip #2#3}{\ifstr{#1}{section}{\MakeTextLowercase{#4}}{#4}}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Lorem ipsum dolor sit amet, consectetuer}
\blindtext[2]
\section{Lorem ipsum dolor sit amet, consectetuer}
\blinddocument
\end{document}
结果