这是对控制的后续行动页脚和正文之间的差距。请记住,目标是在一页内最大化文本。为此,我如何使用drop
或wrap
形状来工作titlesec
(无示例)2)。如何设置参数——我猜是使用\titleformat
——titlesec
使得第一个标题如下所示?
“胡言乱语[尽可能长地跳过]第 1 章”?
最后,我怎样才能减少章节标题和页面顶部之间的间隙?
\documentclass[a6paper, DIV=20]{scrreprt}
%\documentclass{scrreprt}
\usepackage{fontawesome}
\usepackage[T1]{fontenc}
\usepackage{lastpage}
\usepackage{lipsum} % Dummy Text
\usepackage{titlesec}
\usepackage{titleps}
\usepackage{xparse}
\usepackage{tabularx}
\usepackage{hyperref}
\setlength{\footskip}{24pt}
\renewcommand*\familydefault{\sfdefault}
\NewDocumentCommand{\chapterLabel}{}{Ch. \thechapter}
\NewDocumentCommand{\chapterMark}{}{U HAVE TO DEFINE IT!}
\NewDocumentCommand{\setchapterMark}{m}
{%
\RenewDocumentCommand{\chapterMark}{}{#1}
}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\NewDocumentCommand{\myheader}
{mm}
{%
\begin{tabularx}{\textwidth}{@{}XR@{}}#1\end{tabularx}
}
%\newpagestyle{〈name〉}
%[〈global-style〉]
%{〈commands〉}
%setfoot[〈even-left〉][〈even-center〉][〈even-right〉]
%{〈odd-left〉}{〈odd-center〉}{〈odd-right〉}
\newpagestyle{main}
{
\setfoot{\thepage/\pageref{LastPage}}
{}
{\chapterLabel}
}
\newpagestyle{special}
{
\setfoot{\thepage/\pageref{LastPage}}
{}
{\chapterMark}
}
%\titleformat{〈command〉}[〈shape〉]{〈format〉}{〈label〉}{〈sep〉}{〈before-code〉}[〈after-code〉]
%\pagenumbering{gobble}
\pagestyle{main}
\assignpagestyle{\chapter}{empty}
% \titleformat{\chapter} % command
% [drop]%hang|block|display|runin|leftmargin|rightmargin|drop|wrap|frame
% {}% format
% {\chapterLabel}% label
% {}% sep
% {}% before code
% [〈after-code〉]
\begin{document}
\title{Lorem Ipsum}
\author{Dolor S. Amet}
\maketitle
\chapter{Gibberish}
\lipsum[1-2]
\clearpage
\pagestyle{empty}
\setchapterMark{\faBook}
\pagestyle{special}
%\chapter*{\chapterMark~Bibliography}
\chapter*{\myheader{Bibliography}{\chapterMark}}
Let's make that ....
\newpage
... span a second page
\end{document}
答案1
这是一个具有标准report
类的解决方案,当然titlesec
(我必须用 替换fontawesome
我的系统上未安装的fontawesome5
):
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a6paper, margin=20pt, bottom=34pt, footskip=24pt, showframe]{geometry}
\usepackage{fontawesome5}
\usepackage{lastpage}
\usepackage{lipsum} % Dummy Text
\usepackage[pagestyles]{titlesec}
\usepackage{xparse}
\usepackage{tabularx}
\usepackage{hyperref}
\renewcommand*\familydefault{\sfdefault}
\NewDocumentCommand{\chapterLabel}{}{Ch. \thechapter}
\NewDocumentCommand{\chapterMark}{}{U HAVE TO DEFINE IT!}
\NewDocumentCommand{\setchapterMark}{m}
{%
\RenewDocumentCommand{\chapterMark}{}{#1}
}%
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newpagestyle{main}{%
\setfoot{\thepage/\pageref{LastPage}}{}{\chapterLabel}
}%
\newpagestyle{special}{%
\setfoot{\thepage/\pageref{LastPage}}{}{\chapterMark}
}%
\titleformat{\chapter}{\thispagestyle{empty}\sffamily\Huge}{\rlap{\makebox[\textwidth][r]{Ch. \thechapter}}}{0em}{}
\titlespacing*{\chapter}{0pt}{-5ex}{4ex}
\pagestyle{main}
\begin{document}
\title{Lorem Ipsum}
\author{Dolor S. Amet}
\maketitle
%
\chapter{Gibberish}
%
\lipsum[1-5]
\chapter{More Gibberish}
\lipsum[6-12]
\clearpage
\setchapterMark{\faBook}
\pagestyle{special}
\chapter*{Bibliography}
Let's make that
\newpage
... span a second page
\end{document}
答案2
不要将包titlesec
和titleps
KOMA-Script 类一起使用。它们不兼容(即使示例适用于当前版本)。因此,这里有一个建议,不要使用这些包:
\documentclass[a6paper, DIV=20]{scrreprt}
%\providecommand*\Ifstr{\ifstr}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
%\providecommand*\Ifnumbered{\ifnumbered}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{fontawesome}
\usepackage[T1]{fontenc}
\usepackage{lastpage}
\usepackage{lipsum} % Dummy Text
\usepackage[manualmark]{scrlayer-scrpage}
\usepackage{xparse}
\usepackage{tabularx}
\usepackage{hyperref}
\setlength{\footskip}{24pt}
\renewcommand*\familydefault{\sfdefault}
\NewDocumentCommand{\chapterSymbol}{}{}
\NewDocumentCommand{\setchapterSymbol}{m}
{%
\RenewDocumentCommand\chapterSymbol{}{#1}%
}
\addtokomafont{pageheadfoot}{\normalfont}
\clearpairofpagestyles
\ifoot*{\thepage/\pageref{LastPage}}
\ofoot*{\rightmark}
\renewcommand*\chaptermark[1]{\markright{\Ifnumbered{chapter}{Ch. \thechapter}{\chapterSymbol}}}
\renewcommand*\chapterpagestyle{empty}
\NewDocumentCommand{\myheader}
{mm}
{%
\renewcommand\tabularxcolumn[1]{b{##1}}%
\begin{tabularx}{\textwidth}[b]{@{}Xr@{}}%
\parbox[b]{\linewidth}{\raggedright#1}%
\end{tabularx}%
}
\renewcommand*\chapterformat{Ch. \thechapter}
\newcommand*\originalchapterlinesformat{}
\let\originalchapterlinesformat\chapterlinesformat
\renewcommand\chapterlinesformat[3]{%
\Ifstr{#1}{chapter}
{%
\Ifstr{#2}{}
{\myheader{#3}{\chapterSymbol}}
{\myheader{#3}{#2}}%
\setchapterSymbol{}%
}
{\originalchapterlinesformat{#1}{#2}{#3}}%
}
\RedeclareSectionCommand[
beforeskip=0pt,afterindent=false,% if you use an older KOMA-Script version replace the line by beforeskip=-1sp
afterskip=.5\baselineskip plus .05\baselineskip minus .1\baselineskip
]{chapter}
\begin{document}
\title{Lorem Ipsum}
\author{Dolor S. Amet}
\maketitle
\tableofcontents
\chapter{Gibberish}
\lipsum[1-2]
\setchapterSymbol{\faBook}
\addchap{Bibliography}
Let's make that ....
\newpage
... span a second page
\end{document}
结果:
章节标题也可能不适合放在一行中:
\chapter{Gibberish and some more text}
\lipsum[3-4]
答案3
因为这篇文章是关于的titlesec
,而且有人告诉我它会与 冲突Koma-script
,所以我使用的是标准类。把所有东西放在一起,这是我最接近规范的。<>
和()
只是为了看看如何titleformat
工作。
\documentclass{report}
\usepackage{fontawesome}
\usepackage{expl3}
\usepackage[
paper=a6paper,
layout=a6paper,
centering,
,left=1em
,right=1em
,top=1em
,bottom=4em
]{geometry}
\usepackage{lastpage}
\usepackage[explicit]{titlesec}
%\usepackage[DIV=20]{typearea}% throws off the font
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{xparse}
%\setlength{\footskip}{24pt}
\renewcommand*\familydefault{\sfdefault}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\NewDocumentCommand{\myheader}
{mm}
{%
\begin{tabularx}{\textwidth}{@{}XR@{}}#1\end{tabularx}
}
%titlesec
\titleformat{name=\chapter}
[frame]
{\normalfont\bfseries}
{%
\filinner
% \truncchar{left}{2}{\chaptertitlename}. \% An idea...
\chapterLabel
}
{0.5em}
{\large\filouter \textless #1\textgreater}
\titleformat{name=\chapter,numberless}
[frame]
{\normalfont\bfseries}
{%
\filinner
\chapterMark
}
{0.5em}
{\large\filouter (#1)}
\titlespacing{\chapter}{0pt}{*0}{*0}
\NewDocumentCommand{\chapterLabel}{}{Ch. \thechapter}
\NewDocumentCommand{\chapterMark}{}{DEFINE IT!}
\NewDocumentCommand{\setchapterMark}{m}
{%
\RenewDocumentCommand{\chapterMark}{}{#1}
}
% titleps
\newpagestyle{main}
{
\setfoot{\thepage/\pageref{LastPage}}
{}
{\chapterLabel}
}
\newpagestyle{special}
{
\setfoot{\thepage/\pageref{LastPage}}
{}
{\chapterMark}
}
\pagestyle{main}
\assignpagestyle{\chapter}{empty}
\begin{document}
\chapter[Intro]{Introduction}
\lipsum
\newpage% \clearpage
\setchapterMark{\faBook}
\pagestyle{special}
\chapter*{Bibliography}
%\chapter*{\myheader{Bibliography}{\chapterMark}}
Let's make that ....
\newpage
... span a second page
%runin
%leftmargin
%rightmargin
%wrap
%frame
\end{document}