2

I am trying to learn TeX and I need to add a photo placeholder and align it with a title.

I have the following code

\documentclass[margin,line]{res}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}


\begin{document}
\name{\LARGE Person's name}
\photo[64pt][0.15pt]{picture}

\end{document}

And I would like to have the following output: desired output

The code above throws me an error when using \photo[64pt][0.15pt]{picture}. By the way, this is for a CV with photo of the subject in German style (Lebenslauf).

How can I achieve this? I was also looking at this solution but I don't know how to make the placeholder stand above the line of the title.

  • \photo is not standard latex, but rather is peculiar to some document classes. I couldn't find any equivalent for res class. You might want to look at tex.stackexchange.com/questions/80/… – John Kormylo Oct 1 '14 at 22:49
  • I saw an example on the web where they used moderncv package, but I wanted to do it from scratch. I guess that's where the '\photo' comes from. – OneEyeQuestion Oct 1 '14 at 23:30
  • In that case use article and format it yourself. The answer below is one approach. Other formatting commands of interest are \makebox and \raisebox. – John Kormylo Oct 2 '14 at 0:48
1

I would recommend writing a resume in the default article document class. However, since you're using res, you can use the following:

enter image description here

\documentclass[margin,line]{res}
\usepackage{graphicx}
\renewcommand{\namefont}{\bfseries\LARGE}
\begin{document}

\name{\makebox[\textwidth]{Person's name\hfill \includegraphics[height=2\baselineskip]{example-image}}}
\opening
\end{document}
1

One way would be to use a tabular type of environment as the \NameAndPhoto macro does, or without packages use an \hfill between the name and image and then draw the \rule yourself:

enter image description here

Code:

\documentclass{article}
\usepackage{tabularx}
\usepackage{graphicx}

\newcommand*{\NameAndPhoto}[2]{%
    \noindent
    \begin{tabularx}{\linewidth}{@{}Xr@{}}
        \textbf{\Large #1} & \includegraphics[width=2.0cm,height=1.5cm]{#2} \\ \hline
    \end{tabularx}
}

\newcommand*{\NameAndPhotoNonTabular}[2]{%
    \noindent%
    \textbf{\Large #1}\hfill\includegraphics[width=2.0cm,height=1.5cm]{#2}%
    \par\vspace{-0.75\baselineskip}%
    \noindent%
    \rule{\linewidth}{0.4pt}
}


\begin{document}
\NameAndPhoto{Person's name}{../images/EiffelWide}
\bigskip\par
\NameAndPhotoNonTabular{Person's name}{../images/EiffelWide}
\end{document}
  • Would it be possible to do it inside the '\name' tag? I tried adding '\includegraphics[width=2.0cm,height=1.5cm]{photo.jpg}' to it but it's left aligned whereas I would like it to be right aligned, that is with the end (or near it) of the line generated by '\name'. – OneEyeQuestion Oct 1 '14 at 23:42
  • @OneEyeQuestion: That depends on what the definition of \name is? If the only purpose of \name is to typeset the name in bold, the the macros I provided do that so no need to use \name. – Peter Grill Oct 2 '14 at 14:12
  • @PeterGrill There's is an inconvenient with your approach and is that because I am using 'res' (didn't know what was that, but Werner pointed outed correctly) it draws automatically the line. If I use your method 2 things happen: 1) The name isn't properly aligned with the line drawn, that is there is more space between the line and the name. 2) The name is aligned with the contents of the document which begin almost half-way the 'Person's name'. (But I guess this isn't your fault since you couldn't see 'res'). Finally I accept Werner's answer since it is simpler. – OneEyeQuestion Oct 2 '14 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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