# How to start text and image on the same baseline

I need text and images to start at the same level on each page.

With standard LaTeX settings the image seems to start a few points higher then a text. I believe this is due to \topskip. \topskip=0pt should solve the problem, but...

I have a MWE with package geometry where I settle the \texthight in two ways (both have disadvantages):

1. textheight={190mm},heightrounded which results in ragged bottom of the page (unacceptable)
2. lines=40 which gives a proper bottom but there a text is slightly lower then the image (if now other solution the editor will accept this).

What to do to have both text and images start at the same level?

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage[draft,columns=1]{typogrid}
\topskip=0pt
\usepackage[a4paper,layoutsize={176mm,250mm},%
layouthoffset={20mm},layoutvoffset={28.5mm},%
textwidth={115mm},lines=40,%
%textheight={190mm},heightrounded,%
\pagestyle{empty}

\begin{document}
\lipsum[1-5]
\newpage
\includegraphics[width=4cm,height=1cm]{}
\end{document}


To Steven B. Segletes: This what I need http://mleczko.students.wmi.amu.edu.pl/frame.png

This was done by Urlike's answer with +7pt

• The value can be calculated, e.g.: \newdimen\HeightOfM and \settoheight{\HeightOfM}{M}. With standard fonts and class size option (10pt), the result is 6.83331pt, close to 7pt. Alternatively \topskip can be set to that height. – Heiko Oberdiek Jul 31 '13 at 13:55

Your image has a large height and so touch the top. Move it down (adapt the 6pt to your liking):

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage[draft,columns=1]{typogrid}
\topskip=0pt
\usepackage[a4paper,layoutsize={176mm,250mm},%
layouthoffset={20mm},layoutvoffset={28.5mm},%
textwidth={115mm},lines=40,%
%textheight={190mm},heightrounded,%
\pagestyle{empty}

\begin{document}
\lipsum[1-5]
\newpage
abc\includegraphics[width=4cm,height=1cm]{}

\newpage
abc\raisebox{\dimexpr-\height+6pt}{\includegraphics[width=4cm,height=1cm]{}}
\end{document}

• ok, I dont't understand (\dimexpr-\height) but I see it works ;-) Is there any way to do it automatically? – pml Jul 31 '13 at 9:58

This is similar to Ulrike's answer, but using the measure of the textheight itself (a so-called \strut). With this approach, the top of the image can be adjusted from the top of the \strutbox, to get the image height separated from the page frame.

REVISED to reflect questioner's desire to have a gap between frame and image

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{stackengine}
\usepackage[draft,columns=1]{typogrid}
\topskip=0pt
\usepackage[a4paper,layoutsize={176mm,250mm},%
layouthoffset={20mm},layoutvoffset={28.5mm},%
textwidth={115mm},lines=40,%
%textheight={190mm},heightrounded,%
\pagestyle{empty}

\begin{document}
\lipsum[1-5]
\newpage
abc\belowbaseline[-\ht\strutbox+1pt]{\includegraphics[width=4cm,height=1cm]{}}
\end{document}


Note the +1pt suffix to \belowbaseline's optional argument will be the actual gap between the page frame and the top of the image. (In Ulrike's answer, the 6pt is the distance from the text baseline to the top of the letter's height)

• it seems it's not working (I see the image at the top, compile with TeXLive 2013) – pml Jul 31 '13 at 10:16
• @pml I thought you wanted the top of the image aligned with the top top the text. Did I misunderstand? See edited answer above. – Steven B. Segletes Jul 31 '13 at 10:17
• yes, but now the images touches the auxiliary frame, it should be a few point lower (since the text doesn't touch the frame) as in Ulrike's answer, but without guessing 6pt. – pml Jul 31 '13 at 10:22
• @pml: You can naturally use some font dependant value like 1ex or 0.7\ht\strutbox instead of the 6pt (you probably should then call \normalfont\normalsize before the graphic). But you can't avoid to have to play around a bit to get the "best" value or factor as you want a position somewhere in the middle of the line - and this isn't a precise description of a position. – Ulrike Fischer Jul 31 '13 at 10:33
• perfect, I also edited my question and posted an image, unfortunately I can not accept two answers: I will accept the Ulrike's one since it doesn't invoke any additional package, but I do appreciate your answer and explanation. Regards – pml Jul 31 '13 at 10:48