If you want the entire \opening
to be centred, then the following redefinition of \@tablebox
works:
\makeatletter
\def\@tablebox#1{\begin{tabular}[t]{@{}c@{\extracolsep{\fill}}}#1\end{tabular}}
\makeatother
The original \@tablebox
used a l
eft-aligned column:
%\let\latexnofiles\nofiles % If you're using references in your resume
%\let\nofiles\relax % See https://tex.stackexchange.com/a/94528/5764
\documentclass[11pt]{res} % default is 10 pt
%\usepackage{helvetica} % uses helvetica postscript font (download helvetica.sty)
%\usepackage{newcent} % uses new century schoolbook postscript font
\usepackage{latexsym} % to get the \Box symbol
\setlength{\textheight}{10in} % increase text height to fit resume on 1 page
\topmargin=-0.5in % start text higher on the page
\makeatletter
\def\@tablebox#1{\begin{tabular}[t]{@{}c@{\extracolsep{\fill}}}#1\end{tabular}}
\makeatother
\begin{document}
\name{ANDREW J.\ MALONE}
\address{739 Mill Grove Drive \\ Audubon, PA 19403 \\ (215) 555-2216}
\opening
\end{document}
Alternatively, if you wish to have a left-aligned address with your name, use
\makeatletter
\def\@tablebox#1{%
\setbox9=\hbox{\namefont\@name}%
\begin{tabular}[t]{@{}p{\wd9}@{\extracolsep{\fill}}}#1\end{tabular}}
\makeatother
This is a very particular solution to your current setup. A more general solution would be required where the name length and font size could vary. However, without more detail, this should be sufficient.
%\let\latexnofiles\nofiles % If you're using references in your resume
%\let\nofiles\relax % See https://tex.stackexchange.com/a/94528/5764
\documentclass[11pt]{res} % default is 10 pt
%\usepackage{helvetica} % uses helvetica postscript font (download helvetica.sty)
%\usepackage{newcent} % uses new century schoolbook postscript font
\usepackage{latexsym} % to get the \Box symbol
\setlength{\textheight}{10in} % increase text height to fit resume on 1 page
\topmargin=-0.5in % start text higher on the page
\makeatletter
\def\@tablebox#1{%
\setbox9=\hbox{\namefont\@name}%
\begin{tabular}[t]{@{}p{\wd9}@{\extracolsep{\fill}}}#1\end{tabular}}
\makeatother
\begin{document}
\name{ANDREW J.\ MALONE}
\address{739 Mill Grove Drive \\ Audubon, PA 19403 \\ (215) 555-2216}
\opening
\end{document}
On a side note: res
removes the capability to use references within your document. See Problem using etaremune
(reversing the labels of items in a list) for an associated problem and fix for this.
Also, there is no particular need to use the res
class for creating a resume. It is possible to use the default article
class to replicate the layout, yet have some additional freedom in terms of the layout. Moreover, moderncv
provides a stylish take on resumes as well.
Nice question; I solved it by changing \addrentry
and adding something innocuous to \begin{letter}
, that will do nothing if a subsequent \makeopening
command doesn't follow.
In the usual \addentry
command, the last argument is used to build a control sequence that stores the address lines. I add also the building of an opening line, which for MEIER
is stored in \opening@MEIER
. This command is called by \makeopening
(using the hook added before).
\documentclass[
paper=a4,
version=last,
enlargefirstpage,
fontsize=11pt]{scrlttr2}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{xpatch}
%%% Patch the relevant scrlttr macros
\makeatletter
% at the end of \begin{letter}{<name>} store the <name>
\xapptocmd\letter{\gdef\this@letter@to{#2}}{}{}
% this seems complicated, but is needed to strip off
% the backslash from the argument to `\begin{letter}`
% Don't use `\makeopening` if the argument to `\begin{letter}`
% is not obtained via the `.adr` file
% we need to get \opening@MEIER from the fact that
% \this@letter@to expands to \MEIER so we first expand
% \this@letter@to, then \string, so that \@gobble will
% remove the backslash
\newcommand\makeopening{%
\@nameuse{%
opening@%
\expandafter\expandafter\expandafter
\@gobble\expandafter\string\this@letter@to}}
% modify \addrentry to define an opening and
% the address lines as desired
\newif\if@company
\renewcommand\addrentry[9]{%
\def\@tempa{#1}%
\ifx\@tempa\@empty
\else
\@companyfalse
\if#5m%
\@namedef{opening@#9}{\opening{Dear Mr.\ #1,}}%
\else
\if#5w%
\@namedef{opening@#9}{\opening{Dear Mrs.\ #1,}}%
\else
\@namedef{opening@#9}{\opening{Sirs,}}%
\@companytrue
\fi
\fi
\def\@tempa{#2}%
\ifx\@tempa\@empty
\if@company
\@namedef{#9}{#1\\#6\\#3}%
\else
\@namedef{#9}{#1\\#3}%
\fi
\else
\if@company
\@namedef{#9}{#2\\#6\\#3}%
\else
\@namedef{#9}{#2 #1\\#3}%
\fi
\fi
\fi
}
\makeatother
% global koma vars
\setkomavar{fromname}{Max Myname}
\setkomavar{fromphone}{+49\,123\,45678910}
\setkomavar{fromemail}{mymail@gmail.com}
\setkomavar{backaddress}{Max Myname, Some Street 12, 012345 Somewhere}
\setkomavar{fromaddress}{Some Street 12\\012345 Somewhere}
\begin{document}
\setkomavar{subject}{The subject}
\setkomavar{date}{\today}
\setkomavar{place}{Dresden}
\setkomavar{yourmail}{1.1.2013}
\setkomavar{yourref}{76/54/321}
\setkomavar{myref}{123/456/789}
\input{meier.adr}
\begin{letter}{\MEIER}
\makeopening
\lipsum[7]
\closing{Sincerely yours}
\end{letter}
\begin{letter}{\CCI}
\makeopening
\lipsum[7]
\closing{Sincerely yours}
\end{letter}
\end{document}
Here are the two letters (relevant parts only)
Best Answer
You can redefine
\@tablebox
used internally byres.cls
to typeset the name and address; the original definition isand he'res the necessary redefinition:
Perhaps you should consider using a more modern class to typeset your CV? The
moderncv
class is one of the classes available (you can get templates and exampleshere
); other possibilitiescan be explored in CTAN:Writing Applications for a JOB/CV
.