I come from a HTML / CSS background and am used to a particular way of setting margins, floats, etc. As a beginner in TeX, I am having a hard time positioning elements, probably because my mindset is still in CSS positioning and I do not yet grasp the TeX way. After struggling for two hours, I now more or less set up a letterhead that I soon want to set out as a background (which I just learned here). But I feel my code took way too long (I'm learning, but still) to write and not clean (I feel I'm using the wrong commands). So to get a better grasp on positioning, I would like to ask how I should get this done:
This is something I made in HTML and it is supposed to be the header of a letter (used a placeholder logo for this sample). From my standpoint, this is what I need to do:
- Create a page with this particular height and width
- Set the text to appear in the vertical center, and with a little distance from the left
- Float the logo to the right hand side, with a little space from the top and right
After my struggle, this is the code I put together:
\documentclass[a4paper]{article}
\usepackage{graphicx}
\graphicspath{{./img/}}
\usepackage{color}
\usepackage{xcolor}
\definecolor{grey}{HTML}{F4F4F4}
\definecolor{darkgrey}{HTML}{333333}
\usepackage{wrapfig}
\usepackage{fullpage}
\usepackage[margin=0.1cm, paperwidth=497pt, paperheight=40mm]{geometry}
\begin{document}
\pagecolor{grey}
\begin{wrapfigure}{r}{3cm}
\includegraphics[height=3cm]{html5}
\end{wrapfigure}
\Large \textcolor{darkgrey}{\\ \\ \textbf{Our Company} \\ Our Slogan}
\end{document}
This is what I get:
My problems:
- I had to use several newlines to get the text centered vertically. If I used
vfill
, my logo jumped away. - The logo borders are 'rugged', whereas they are smooth in the HTML version. The logo is high resolution and looks fine if I zoom in in the PDF to 500%, but it looks bad at 100%.
- The way I float the image feels wrong. It's quite some code to just float it (remember, I come from
float:right
, so I am biased here, maybe this is the way to go)... is that how it should be?
Any other tips on better understanding floating and margins is appreciated, especially taking into consideration these kinds of 'designs' rather than articles and more standard text documents.