減少 scrartcl 中標題和上邊距之間的空間

減少 scrartcl 中標題和上邊距之間的空間

如何使用scrartcl下面的 KOMA-Script 類別來減少範例文件中標題和上邊距之間的間距?

\documentclass[a4paper,11pt]{scrartcl}
\usepackage{blindtext}
\title{This is a nice title!}
\subtitle{This is an even nicer subtitle!}
\author{John Doe}
\begin{document}
\maketitle
\section{Introduction}
\blindtext
\blindtext
\end{document}

我已經嘗試過了解決方案,其中titling使用了包,但是\subtitle不再顯示。

我正在尋找一種快速而骯髒的解決方案,例如使用\vspace{-10px}或類似的東西。

答案1

好吧,如果你想要它快速而骯髒,只需添加\vspace{-1cm}到標題命令中:

\title{\vspace{-1cm}This is a nice title!}

1cm根據您的需求進行更改。在下面的 MWe 中,我添加了包showframe來視覺化打字區域和邊距。

具有以下 MWE

\documentclass[a4paper,11pt]{scrartcl}

\usepackage{blindtext}
\usepackage{showframe}

\title{\vspace{-1cm}This is a nice title!}
%\title{This is a nice title!}
\subtitle{This is an even nicer subtitle!}
\author{John Doe}


\begin{document}

\maketitle
\section{Introduction}
\blindtext
\blindtext
\end{document}

你得到結果:

產生的pdf文件

答案2

免責聲明:這個答案有點老套,因為它嚴重依賴於原始碼scrartcl.cls作為就是現在,並且因為它的任何更改都可能使此駭客無效。受到了啟發透過這個答案,它不需要編輯標題,這很好。

\documentclass{scrartcl}
\usepackage{blindtext} % Just for the demo.
\title{This is a nice title!}
\subtitle{This is an even nicer subtitle!}
\author{John Doe}

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@maketitle}{\vskip2em}{% Insert here the space you want between the top margin and the title.
    \vspace{-10em} % Example of smaller margin. 
}{}{}
\xpatchcmd{\@maketitle}{\vskip.5em}{% Insert here the space you want between the title and the subtitle
    \vskip5em % Example of bigger margin.
}{}{}
\makeatother

\begin{document}
\maketitle
\section{Introduction}
\blindtext
\blindtext
\end{document}

給出

在此輸入影像描述

相關內容