使用 fancyhdr 避免不同格式的標題頁

使用 fancyhdr 避免不同格式的標題頁

我一直在嘗試學習一些 LaTeX 格式,但我陷入了一些本應非常簡單的問題上,但似乎我只找到了相當複雜的方法來在線解決它。當我在嘗試將頁碼更改為右下角時使用該\fancyhdr套件時,我在第一頁上遇到了問題。如果我刪除就可以了。\maketitle\maketitle

\documentclass[a4paper,12pt,twoside]{article}
\usepackage{multicol}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}

\geometry{
 a4paper,
 total={170mm,257mm},
 left=30mm,
 right=20mm,
 top=20mm,
 bottom=20mm,
 }
\pagestyle{fancy}
\fancyhf{}
\rfoot{\thepage}


\title{Lorem Ipsum}
\author{XMen}
\date{\today}

\begin{document}
\begin{multicols}{2}
[
\maketitle
]

答案1

製作自己的自訂標題頁比內建標準更容易,有時也更合適\maketitle

下面是一個可以根據您的要求自訂的範例

頁碼已被註解掉並且是可選的

垂直間距可依使用者要求調整

在此輸入影像描述

\documentclass[12pt,a4paper]{report}
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
    \centering
    \includegraphics[width=0.15\textwidth]{example-image-1x1}\par\vspace{1cm}
    {\scshape\LARGE Columbidae University \par}
    \vspace{1cm}
    {\scshape\Large Final year project\par}
    \vspace{1.5cm}
    {\huge\bfseries Pigeons love doves\par}
    \vspace{2cm}
    {\Large\itshape John Birdwatch\par}
    \vfill
    supervised by\par
    Dr.~Mark \textsc{Brown}

    \vfill

% Bottom of the page
    {\large \today\par}
    % \thepage%optional
\end{titlepage}
\end{document}

標題頁的其他資源

https://en.wikibooks.org/wiki/LaTeX/Title_Creation

展示 TeX 完成的漂亮標題頁

https://github.com/johannesbottcher/titlepageExamples/

如果您認為答案符合您的要求,請點擊左側的紅色三角形及其下方的勾號來對答案進行投票

請注意,您發布的 MWE 代碼不完整,只能對您的要求進行估計。

答案2

\maketitle命令確實如此\thispagestyle{plain}

您有兩個選擇:要么重新定義plain頁面樣式

\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
  \fancyfoot[R]{\thepage}% equivalent to \rfoot{\thepage}
}
\pagestyle{plain}

\thispagestyle{fancy}之後發出\maketitle並保持程式碼不變(好吧,我添加\renewcommand{\headrulewidth}{0pt}是為了刪除令人討厭的行)。

\documentclass[a4paper,12pt,twoside]{article}
\usepackage{multicol}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}

\usepackage{lipsum} % for filler text

\geometry{
 a4paper,
% total={170mm,257mm},
 left=30mm,
 right=20mm,
 top=20mm,
 bottom=20mm,
 }

\pagestyle{fancy}
\fancyhf{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}


\title{Lorem Ipsum}
\author{XMen}
\date{\today}

\begin{document}

\begin{multicols}{2}[\maketitle\thispagestyle{fancy}]
\lipsum[1-10]

\end{multicols}

\end{document}

隨著“重新定義風格plain”:

\documentclass[a4paper,12pt,twoside]{article}
\usepackage{multicol}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}

\usepackage{lipsum} % for filler text

\geometry{
 a4paper,
% total={170mm,257mm},
 left=30mm,
 right=20mm,
 top=20mm,
 bottom=20mm,
 }

\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
  \fancyfoot[R]{\thepage}%
}
\pagestyle{plain}


\title{Lorem Ipsum}
\author{XMen}
\date{\today}

\begin{document}

\begin{multicols}{2}[\maketitle]
\lipsum[1-10]

\end{multicols}

\end{document}

請注意,我評論了該total行:指定文字寬度、左邊距是沒有意義的右邊距(垂直尺寸也類似)。

在此輸入影像描述

相關內容