我是社区的新成员,也是 latex 的普通用户,我觉得它真的很棒,即使有时它让我抓狂,我在想要重写的文件时遇到了一点问题,我知道如何使用 fancyhdr 包等,但我发现这个包什么也没用,我想做一个这样的标题:
我在谷歌上搜索了很多,没有任何结果,谢谢你的帮助
-编辑:抱歉,我忘记了我的代码:
\documentclass[12pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ulem}
\usepackage[francais]{babel}
\usepackage{url} % Pour écrire des adresses cliquables.
\usepackage{mathptmx}
\usepackage{newcent} % Pour changer le pack de police.
\usepackage[top=3cm, bottom=3cm, left=4cm, right=3cm]{geometry} % Les marges.
\usepackage{amsmath,amssymb}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\headrulewidth{0.6pt}
\fancyhead[R]{1}
\begin{document}
fffff
\end{document}
答案1
标题可以设置为tabular*
,作为起点,给出以下示例(注意文件内的注释):
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}
% The date is used as an example, how variable data can
% be managed in the header.
% Macro `\headdate{...}' defines the macro `\theheaddate'
% with the given date. `\theheaddate' is used later in
% the fancy headers.
\newcommand*{\headdate}[1]{%
\def\theheaddate{#1}%
}
% The default for the date (\theheaddate) is "YYYY/MM" of the current date.
\headdate{\the\year/\ifnum\month<10 0\fi\the\month}
% The images contains `2010/11' as date.
% \headdate{2010/11}
% Defining the fancy page style:
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\renewcommand*{\headrulewidth}{0pt}
\renewcommand*{\footrulewidth}{0pt}
% The header as table. Because we are using the french `:', the shorthand
% must be activated, because we are still in the preamble. Package babel
% activates them at `\begin{document}'.
\shorthandon{:}
\newcommand*{\theheader}{%
\begin{tabular*}{\textwidth}[b]{@{\extracolsep{\fill}}cc@{}}%
\multicolumn{2}{r@{}}{\thepage}\\%
\hline
\mbox{}\\%
UNIVERSITE MOHAMMED PREMIER
& Ann\'ee Universitaire \theheaddate\\
\textsc{Facult\`e des Sciences}
& Fili\`eres SM\\
\textsc{D\`epartement de Math\`ematiques}
& Semestre S1\\
\textsc{et Informatique}
&\\
\textsc{-Oujda-}
& Responsable: M.FILALI\\
\end{tabular*}%
}
\chead{\theheader}
% The shorthand is turned off to avoid trouble with the loading of
% other packages.
\shorthandoff{:}
% As the header table is much larger than the standard `\headheight`,
% these calculations fixes the `\headheight` by moving space from
% the text body to the header.
\addtolength{\textheight}{\headheight}
\settoheight{\headheight}{\vbox{\hbox{\theheader}\kern0pt}}
% The `\vbox{...\kern0pt}' construction is a trick to simulate the
% missing `\settototalheight'.
\addtolength{\textheight}{-\headheight}
% For debugging, option `showframe' shows the page layout
% and option `pass' tells `geometry' not to change the layout, but
% to use the current values.
\usepackage[pass,showframe]{geometry}
\begin{document}
\section{Hello World}
Start of line\hfill end of line.
\end{document}
评论:
- 我没有像图片中那样将右侧块移到右边距。我认为,如果右侧块与页码对齐,看起来会更好。