我有一个相对简单的 LaTeX 文档,其中包含几个部分和小节,一切都很好,但是:我想为每个部分都有一个自定义设计的标题页。(顺便说一下,MWE 在底部!)我的目录如下所示:
现在,带有新部分(例如 2A 秒...)的页面如下所示:
但我更希望有一些引人注目的东西!这是我的想法,我希望看到例如第 2 部分:
您会发现 MWE 就在下面!
我现在的问题是:我该如何为我的部分创建这些好看的标题页?我认为该titlesec
软件包有一些可能性。但我自己不擅长尝试。有人能帮我吗?任何帮助我都非常感谢!
\documentclass[%
a4paper,
11pt,
headsepline,
footsepline,
]
{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{seqsplit}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{ulem}
\usepackage[version=3,arrows=pgf]{mhchem}
\usepackage[pdf]{pstricks}
\usepackage{acronym}
\usepackage{wasysym}
\usepackage{rsphrase}
\usepackage{siunitx}
\usepackage{tikz}
\usepackage{float}
\usepackage{geometry}
\geometry{bottom=3.5cm}
\geometry{top=3.5cm}
\geometry{left=2.5cm}
\geometry{right=2.5cm}
\usepackage{enumerate}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{subfigure}
\usepackage{url}
\usepackage{setspace}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{graphicx}
\usepackage[labelfont=bf,format=plain]{caption}
\usepackage[linkcolor=black,citecolor=black]{hyperref}
\makeatletter
\@addtoreset{figure}{section}
\@addtoreset{table}{section}
\makeatother
\renewcommand{\thefigure}{\thesection.\arabic {figure}}
\renewcommand{\thetable}{\thesection.\arabic{table}}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\sisetup{%
obeyall,
per=frac,
decimalsymbol=comma,
unitmode=text
}
\hbadness=10000
\vbadness=10000
\hyphenpenalty=100000
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\linespread{1.25}
\begin{document}
\sloppy
\thispagestyle{empty}
\LARGE
\vspace{0.5cm}
\begin{center} \LARGE
\textbf{\LARGE XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\}
\textbf{\LARGE XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\}
\end{center}
\vspace{1.0cm}
\begin{center}
\Large
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
\end{center}
\vspace{1.0cm}
\begin{table}[!h]
\Large
\begin{tabular}{ll}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX & \\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX& \\
\end{tabular}
\normalsize
\end{table}
\vspace{0.5cm}
\begin{table}[!b]
\Large
\begin{tabular}{ll}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXh\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\\
v & \\
\end{tabular}
\normalsize
\end{table}
\normalsize
\clearpage
\thispagestyle{empty}
\setcounter{page}{1}
\pagenumbering{Roman}
\clearpage
\thispagestyle{plain}
\section*{section X}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX \\
\large
\paragraph{XXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
\clearpage
\thispagestyle{empty}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\phantom{oben}
\begin{flushright} \LARGE
\textbf{\LARGE It will be fine.\\}
\end{flushright}
\vspace{1.0cm}
\clearpage
\thispagestyle{plain}
\tableofcontents
\clearpage
\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\clearpage
\listoftables
\addcontentsline{toc}{section}{List of Tables}
\clearpage
\clearpage
\section*{some other hidden chapter}
XXXXXXXXXXXXXXXXXXXXXXXXXXXX
\clearpage
\setcounter{page}{1}
\pagenumbering{arabic}
\section{A first very nice and fancy looking title}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsection{subsectionn 1-1}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsection{subsectionn 1-2}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsubsection{subsubsection 1-2-1}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\section{A second very nice and fancy looking title}
\subsection{subsection 2-1}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsection{subsection 2-2}
\subsubsection{subsubsection 2-2-1}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsubsection{subsubsection 2-2-1}
\subsection{subsection 2-3}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\section{A third very nice and fancy looking title}
\subsection{subsection 3-1}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsection{subsection 3-2}
\subsubsection{subsubsection 3-2-1}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\subsubsection{subsubsection 3-2-1}
\subsection{subsection 3-3}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
\end{document}
答案1
以下是我修补命令以获得所需格式的解决方案\section
。附加数据(即示例图片中的“这里有一小段文字...”部分)是\sectionpreamble
在发出命令之前通过以下方式收集的\section
:
\sectionpreamble{%
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
}
\section{There will be a very long title here that spans lots and lots and lots and lots and lots of lines}
完整的代码如下:
\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{xcolor}
\makeatletter
\newdimen\thesectionwdmax
\newdimen\sectiontitlewd
\AtBeginDocument{%
\setbox0=\hbox{\scalebox{5}{99}}
\thesectionwdmax\wd0
\sectiontitlewd\dimexpr\textwidth-\thesectionwdmax-2.25cm\relax
}
\def\section{\par
\addvspace{4ex}%
\@afterindentfalse
\secdef\@sec\@ssec}
\def\@sec[#1]#2{%
\ifnum \c@secnumdepth>\m@ne
\refstepcounter{section}%\@maybeasf%
\addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
\else
\addcontentsline{toc}{section}{#1}%
\fi
{\parindent\z@
\raggedright
\interlinepenalty \@M
\thispagestyle{empty}
\normalfont
\setbox0=\vbox{\parbox{\sectiontitlewd}{\noindent\huge#2}}
\sectfont
\raisebox{-1em}{\parbox[c]{\thesectionwdmax}{\noindent\null\hfill\scalebox{5}{\thesection}}}
\hspace{.25cm}
\raisebox{1em}{\parbox[t][\dimexpr\ht0+\dp0\relax]{1em}{\leaders\vrule\vfill}}
\hspace{1cm}
\parbox[t]{\sectiontitlewd}{\noindent\huge#2}
\vfill\printsectionpreamble\vfill
\sectionmark{}\par}%
\nobreak
\@afterheading
\clearpage}
\def\@ssec#1{%
{\parindent\z@
\raggedright
\interlinepenalty \@M
\thispagestyle{empty}
\sectfont #1
\vfill\printsectionpreamble\vfill
\sectionmark{}\par}%
\nobreak
\vskip 3ex
\@afterheading
\clearpage}
\def\printsectionpreamble{%
\ifx\currentsecpreamble\empty\else
\colorbox{pink}{\parbox{\textwidth}{\normalfont\normalsize\currentsecpreamble}}\fi
\let\currentsecpreamble\empty}
\def\sectionpreamble#1{\gdef\currentsecpreamble{#1}}
\makeatother
\begin{document}
\sectionpreamble{%
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
}
\section{There will be a very long title here that spans lots and lots and lots and lots and lots of lines}
%...
\end{document}
答案2
以下是重新定义 KOMA-Script 命令的建议\sectionlinesformat
:
\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{xcolor}
\newdimen\thesectionwdmax
\newdimen\sectiontitlewd
\AtBeginDocument{%
\setbox0=\hbox{{\usekomafont{disposition}\usekomafont{section}\scalebox{2}{99}}}%
\thesectionwdmax\wd0%
\sectiontitlewd\dimexpr\textwidth-\thesectionwdmax-.75cm-1pt\relax
}
\renewcommand\sectionformat{\protect\scalebox{2}{\thesection}}
\addtokomafont{section}{\huge}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\ifstr{#1}{section}
{\ifstr{#3}{}
{\@hangfrom{\hskip #2#3}{#4}}
{%
\begin{tabular}{@{}r@{\hspace{.25cm}\vrule width 1pt\hspace{.5cm}}l@{}}
\parbox{\thesectionwdmax}{\centering#3}%
&%
{\parbox{\sectiontitlewd}{\raggedright#4}}%
\end{tabular}%
}%
}
{\@hangfrom{\hskip #2#3}{#4}}%
}
\newcommand\sectionpreamble[1]{{%
\vfill
\setlength\fboxsep{2em}%
\colorbox{lightgray}{%
\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}
{\raggedright #1}%
}%
\vfill
\clearpage
}}
\makeatother
\usepackage{lipsum}
\begin{document}
\tableofcontents
\section{There will be a very long title here that spans lots and lots and lots and lots and lots of lines}
\lipsum[1]
\section{A short title}
\lipsum[2]
\clearpage
\section{There will be a very long title here that spans lots and lots and lots and lots and lots of lines}
\sectionpreamble{\lipsum[1]}
\lipsum[5-6]
\section{Another section}
\lipsum
\addsec{Unnumbered section}
More text ...
\end{document}