如何使標題在自訂標題中居中?

如何使標題在自訂標題中居中?

現在我的標題看起來像這樣 在此輸入影像描述

正如您所看到的,居中有點偏離。我真正希望它看起來沒有元素 1 和元素 3,而是以「CS 2800」和「作業 1」為中心。

如果有人能告訴我該怎麼做,我將不勝感激!我使用的乳膠代碼是這樣的:

% Use this template to write your solutions

\documentclass[12pt]{article}
\usepackage[intlimits, sumlimits]{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{microtype}

% Set the margins
%
\setlength{\textheight}{8.5in}
\setlength{\headheight}{.25in}
\setlength{\headsep}{.25in}
\setlength{\topmargin}{0in}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}

% Macros
\newcommand{\myN}{\hbox{N\hspace*{-.9em}I\hspace*{.4em}}}
\newcommand{\myZ}{\hbox{Z}^+}
\newcommand{\myR}{\hbox{R}}

\newcommand{\myfunction}[3]
{${#1} : {#2} \rightarrow {#3}$ }

\newcommand{\myzrfunction}[1]
{\myfunction{#1}{{\myZ}}{{\myR}}}


% Formating Macros

\newcommand{\myheader}[6]
{\vspace*{-0.5in}
\noindent
{#1} \hfill {#2} \hfill {#3}

\noindent
{#4} \hfill {#5} \hfill {#6}

\noindent
\rule[8pt]{\textwidth}{1pt}

\vspace{1ex} 
}  % end \myheader 

\newcommand{\myalgsheader}[0]
{\myheader
{ {}}
{ {\Large CS 2800}}
{ {}}
{ {Monica}}
{ {Homework 1}}
{ {February 8, 2015}}
}

%%%%%% Begin document with header and title %%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\myalgsheader

\pagestyle{plain}

% \myhwtitle{x}{y}{clem, Lee, Clement}
% Example : \myhwtitle{1}{4}{Your name here}

\bigskip

% begin Solution 
Your problem solution.
% end Solution 

\end{document}

答案1

我將加載該fancyhdr包並將以下程式碼放在序言中:

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Monica}
\chead{\begin{tabular}[b]{c}
       \Large CS2800 \\ Homework 1
       \end{tabular}}
\rhead{February 8, 2015}

文檔的正文將這樣開始:

\begin{document}
\pagestyle{plain}
\thispagestyle{fancy}
...

在此輸入影像描述

答案2

與 有點不同@米科解決方案稍後。

\documentclass{report}
\usepackage{lipsum}
\usepackage[showframe,head=2.5em]{geometry}
\usepackage{fancyhdr}
\lhead{%
\begin{tabular}{@{}l}
Element 1\\Monica
\end{tabular}%
}
\rhead{%
\begin{tabular}{r@{}}
Element 3\\\today
\end{tabular}%
}
\chead{%
\begin{tabular}{c}
{\large CS 2800}\\Homework 1
\end{tabular}%
}

\begin{document}
\pagestyle{fancy}
\lipsum[1]
\end{document}

在此輸入影像描述

相關內容