Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

how can i be able to create this one by simply making this into command?

ouput:

\begin{center}
\myname{Mike Backlund}
\myschool{School 1}
\myschool{School 2}
\end{center}

display would be:

                            Mike Backlund
                                School1
                                School2

Hope you could help me

share|improve this question
add comment

2 Answers

I provide two possible and simple solutions. The first disregards from your three commands \myname and \myschool and makes one new command with three input variables. the second uses three input variables \myname, \myschoolone and \myschooltwo. The MWE will provide two identical layouts using these two approached.

\documentclass{article}
% Single command
\newcommand{\myheader}[3]{
\begin{center}
#1\\ #2\\ #3
\end{center}
}
% defining three variables
\newcommand{\myname}{Mike Backlund}
\newcommand{\myschoolone}{School 1}
\newcommand{\myschooltwo}{School 2}


\begin{document}

% alternative 1:
\myheader{Mike Backlund}{School 1}{School 2}
\vskip5mm % just to separate them a bit

% alternative 2:
\myheader{\myname}{\myschoolone}{\myschooltwo}

\end{document}

Since it is possible to feed the header macro with both commands and text, you could mix them as well. I assume that you want the name and school definitions so that you can use them elsewehere in the document which makes the second approach more appropriate.

share|improve this answer
add comment

If you mean 'the' header, you could do this with fancyhdr (or perhaps with your documentclass's facilities):

\documentclass{article}

\newcommand{\myname}{Mike Backlund}
\newcommand{\schooli}{School 1}
\newcommand{\schoolii}{School 2}

\usepackage{lipsum,fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{\myname\\\schooli\\\schoolii}% or in one of the other fancyhdr locations
\lhead{}
\lfoot{}
\cfoot{}
\rfoot{}
% \renewcommand{\headrulewidth}{0pt}% uncomment to 'remove' line below header

\begin{document}

\lipsum\lipsum

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.