[Tex/LaTex] Align text and logo

horizontal alignmentvertical alignment

I'm trying to find a way to place a logo at the top left of the page, with at the same height and right aligned my information (eg name, adress). The rest of the text has to be placed below that.

I can't find how to do that. My problems are

  1. my information (name) is not on the same height as the logo;
  2. the text just starts under my name, on the right side of the logo, not under it.

Most search results I saw are about headers and footers and I'm not looking for that.

My code:

\begin{wrapfigure}{l}{0.5\textwidth}
  \begin{center}
    \includegraphics[width=0.5\textwidth]{D:/SkyDrive/Backup/Latex/logo.jpg} 
  \end{center}
\end{wrapfigure}

\begin{flushright}
    \noindent name\\
    info\\
    \today
\end{flushright}

Text

Best Answer

This seems like a crude way of doing it, but it is fairly straight forward:

enter image description here

\documentclass{article}
\usepackage{array,graphicx,lipsum}% http://ctan.org/pkg/{array,graphicx,lipsum}
\begin{document}
\noindent\begin{tabular}{@{}p{.5\textwidth}@{}>{\raggedleft\arraybackslash}p{.5\textwidth}@{}}
   & My name \\ & My street \\ & My city \\ & My postal code \\ 
  \smash{\includegraphics[height=5\normalbaselineskip]{example-image-a}} & My country
\end{tabular}

\lipsum
\end{document}

I've made the height of the image be equivalent to the height of the name/address portion (5 lines or \normalbaselineskips). Inserting the image on the same line as the last entry of your address allows you to use \smash to avoid any vertical adjustment within the tabular.

Some components involved in the solution:

  • \noindent: Removed the regular paragraph indent inserted when starting a paragraph (note that this happens with the first Lorem ipsum paragraph below the image);
  • @{} in the tabular column specification removes the inter-column spacing inserted usually between adjacent columns like. This space inside a tabular is given by \tabcolsep;
  • >{<stuff>}: This is a directive offered by the array package that inserts <stuff> before the start of the cell. An analogous <{<stuff>} is also provided (but not used) for inserting <stuff> after the end of the cell. I insert \raggedleft to make the cell contents be flush with the right margin. There's also \arraybackslash which is a correction tool when using the > and < directives, re-establishing the functionality of \\;
  • p{.5\textwidth}: Both columns in the tabular are set in paragraph mode/style with a width of .5\textwidth - half the text block width.
  • \smash: removes any vertical height of an object which would otherwise influence the line gap between successive rows in the tabular.
  • \normalbaselineskip: The regular \baselineskip that is used outside the tabular environment is captured in \normalbaselineskip for use inside the tabular, if needed. I made the image as high as 5 lines, since my personal details spanned 5 lines.