将标题移至页面顶部但保留顶部边距值

将标题移至页面顶部但保留顶部边距值

目前 LaTeX 存在很多问题。我需要文章的顶部边距为 33 毫米,但出于某种原因,我的标题页的边距要大得多。有没有我忽略的简单修复方法?

梅威瑟:

\documentclass[a4paper,oneside,12pt]{article}
\usepackage[english]{babel} % formatting rules for the English language
\usepackage[T1]{fontenc} % proper formatting for accented characters and non-standard characters such as pipelines
\usepackage[top=33mm, bottom=38mm, left=26mm, right=20mm]{geometry} % page layout
\usepackage{lmodern} % font formatting
\usepackage{float} % allow floating environments such as figures
\usepackage{amsmath} % math eqn formatting
\usepackage{amssymb} % math fonts
\title{\bf{\fontsize{14pt}{2pt} Title}}
\author{\fontsize{14pt}{2pt} Author names}
\date{}
\begin{document}
\maketitle
\end{document}

答案1

只是为了纠正代码中的一些错误:

  1. 不要使用\bfLaTeX 中已弃用的 which,而应使用\bfseriesor \textbf(例如双字母字体样式命令 (\bf,\it,...) 会在 LaTeX 中复活吗?

  2. 使用12pt作为文档类的选项,使用\large而不是\fontsize{14pt}{2pt}(顺便说一下,它应该是这样的\fontsize{14pt}{17pt}\selectfont)。结果是相同的。

要将标题放在页面顶部,您可以\@maketitle借助包\patchcmd中的命令来修补宏etoolbox,即在序言中添加以下几行:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@maketitle}
  {\null\vskip 2em\begin{center}}
  {\centering}
  {}
  {}
\patchcmd{\@maketitle}
  {\end{center}}
  {}
  {}
  {}
\makeatother

showframeMWE(从中删除选项geometry,只是为了表明它有效)

\documentclass[a4paper,oneside,12pt]{article}
\usepackage[english]{babel} % formatting rules for the English language
\usepackage[T1]{fontenc} % proper formatting for accented characters and non-standard characters such as pipelines
\usepackage[top=33mm, bottom=38mm, left=26mm, right=20mm, showframe]{geometry} % page layout
\usepackage{lmodern} % font formatting
\usepackage{float} % allow floating environments such as figures
\usepackage{amsmath} % math eqn formatting
\usepackage{amssymb} % math fonts

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@maketitle}
  {\null\vskip 2em\begin{center}}
  {\centering}
  {}
  {}
\patchcmd{\@maketitle}
  {\end{center}}
  {}
  {}
  {}
\makeatother

\title{\large\bfseries Title}
\author{\large Author names}
\date{}
\begin{document}
\maketitle
\end{document} 

输出:

在此处输入图片描述

答案2

您可以使用包\droptitle中定义的长度 titling。另一方面,您的前言中有几个错误:首先,第二个参数是\fontsize两个连续行之间的垂直空间值,因此它不应小于字体本身的设计大小。通常,它大约大 20%。其次,如果您不添加\selectfont,它是无效的,正如您在以下代码中看到的那样:我写了一个两行标题,在第一行中我“忘记”写 \selectfont;它导致第一行具有默认大小(\LARGE,大约 20pt),而不是 14 pt。

    \documentclass[a4paper,oneside,12pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[english]{babel} % formatting rules for the English language
    \usepackage[T1]{fontenc} % proper formatting for accented characters and non-standard characters such as pipelines
    \usepackage{lmodern} % font formatting
    \usepackage[english]{babel} % formatting rules for the English language
    \usepackage[top=33mm, bottom=38mm, left=26mm, right=20mm, showframe]{geometry} % page layout
    \usepackage{float} % allow floating environments such as figures
    \usepackage{amsmath} % math eqn formatting
    \usepackage{amssymb} % math fonts
    \usepackage{titling}
    \droptitle = -20mm
    \title{\bfseries\fontsize{14}{17} Title\\\fontsize{14}{17}\selectfont A subtitle}%
    \author{\fontsize{14}{17}\selectfont Author names}
    \date{}
    \begin{document}

    \maketitle

    Blahblahblah…
    \end{document} 

在此处输入图片描述

相关内容