I've been learning LaTeX and this community has been very helpful. Currently, I'm trying to set up corporate letters but as a newbie I'm encountering a variety of challenges, so I'm posting them one by one instead of putting it in the comments... maybe this helps others as well.

Anyway, I am trying to implement this answer that indicates that I can use vbox to float an image to the right of my header. I almost have this working, but I now try to adjust this to get my logo to stick to the top of the page. So I want to have this at the right top of my document. This is quite difficult! When I place the vbox, it creates unwanted spacing, for some odd reason. So I can not get the logo to be at the right top, even though I 'reset' every possible margin to 0 (in my opinion). Here is my distilled code:

\usepackage[margin=0cm, paperwidth=215.9mm, paperheight=30mm,top=0cm]{geometry}



\fbox{\vbox to 0pt{\hfill\fbox{\includegraphics[height=3cm]{logo}}}}


I've used a full black logo for illustrative purposes. Here you can see this:

enter image description here

The black line is the vbox border. For some reason, it jumps down. The only way to get rid of this that I found out about is this:

Make an invisible vbox

Which means that I need to add:

\vbox to 0pt{...}\prevdepth=\theprevdepth

But there are two problems with this:

  • I get an error with I try this (Improper \prevdepth.)
  • More importantly, I really want to understand my code at this point, and get to master the basics of positioning elements. This feels overcomplicated and I do not understand it at all.

Is there any easy way to position an image at the right top of a document?

  • The latest TUGboat has an article about designing letters with the hletter package. If you haven't had a chance to look at it then it may be worth your while because it may save you some work.
    – user10274
    Feb 11, 2012 at 6:55

4 Answers 4


The \vbox is anchored to the baseline. Also, since there is an additional \topskip at the top of the page between the header and the first line of text. So, jumping vertically -\baselineskip-\topskip pushes the \vbox of height 0pt tight against the upper part of the page boundary.

Here's your MWE:

enter image description here

\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fullpage}% http://ctan.org/pkg/fullpage
\usepackage[margin=0cm, paperwidth=215.9mm, paperheight=30mm]{geometry}

\fbox{\vbox to 0pt{\hfill\fbox{\includegraphics[height=3cm]{html5}}}}

Some comments about the code:

  • You have to use \vspace* for vertical space at the top of the page;
  • \dimexpr...\relax is used as a dimension expression for combining lengths (or dimensions). You can also include the calc package which allows you to forego this notation and use -\baselineskip-\topskip as is;
  • I use \setlength rather than \<len>=<dim> - that's just the LaTeX way; the latter is the TeX way;
  • margin=0cm is equivalent to left=0cm,right=0cm,bottom=0cm,top=0cm in geometry, so I dropped top=0cm;
  • I set \fboxsep to -\fboxrule. This way the rule is actually drawn within the bounding box. Otherwise it would add .4pt to each of the sides (a total of .8pt vertically and horizontally) even if you use \setlength{\fboxsep}{0pt};
  • Loading xcolor is sufficient, so you don't need to load color.

With TikZ and the current page node, you can place the image right at the top right corner of the page, just set the image node anchor to north east. All you need to add to your code is


in the preamble, and then in your code

\begin{tikzpicture}[remember picture, overlay]
  \node [anchor=north east, inner sep=0pt]  at (current page.north east)

logo at top right


It is normally sufficient to say:


Geometry dimensions can be negative as well. In the above top is set to top=-10pt.

  • 1
    ...since \topskip is 10pt.
    – Werner
    Feb 11, 2012 at 5:18

Without using a special geometry setting:



enter image description here

  • Nice solution :)
    – Nivir
    Jul 31, 2017 at 20:46
  • It's indeed a very simple solution. Can I change the location of the image so to have some margins?
    – myradio
    Dec 10, 2018 at 10:09
  • play with the 1in value
    – user2478
    Dec 10, 2018 at 10:12

You must log in to answer this question.

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