3

Right now my title looks like this enter image description here

As you can see, the centering is a bit off. What I really would like it to look like is not have element 1 & element 3 and have "CS 2800" & "Homework 1" centered.

If anyone could tell me how to do that it would be very much appreciated! The latex code that I'm using is this:

% 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}

2 Answers 2

3

I would load the fancyhdr package and place the following code in the preamble:

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

The body of the document would then start off like this:

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

enter image description here

1
  • The instructions \pagestyle{plain}\thispagestyle{fancy} make sure that the "fancy" page style is used only on the first page of the document.
    – Mico
    Feb 4, 2016 at 19:12
2

A little bit different from @Mico solution and a little bit later.

\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}

enter image description here

2
  • +1. I can't tell if the header is supposed to show up on every page of the document or just on the first one.
    – Mico
    Feb 4, 2016 at 19:11
  • @Mico, me too. Specially because of those lot of new commands with arguments.
    – Sigur
    Feb 4, 2016 at 19:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .