9

Lets' say I want to emulate an underlined signature; so I have this image:

testing.png

... which has been generated with the ImageMagick convert line included in this MWE:

\documentclass{article}
\usepackage{graphicx}

% create testing.png using ImageMagick convert
% call w/ `pdflatex -shell-escape test.tex` to have the command run
% note: \includegraphics ignores the 150dpi set here, and will
% output bigger image than 2x0.6 in; *unless* -units pixelsperinch is set
% - but then it may give wrong resoltion in `identify -v`?...

\immediate\write18{convert -units pixelsperinch -density 150 -size 300x100 xc:white -draw "decorate UnderLine font Comic-Sans-MS-Regular font-size 30 fill dodgerblue text 20,70 ' Testing '" testing.png}

\begin{document}

Just testing something here... Lorem ipsum dolor sit amet,...

\noindent%
Attempt at signature: \makebox[0pt][l]{\hspace*{2cm}\vspace*{-2cm}\includegraphics{testing.png}}\hrulefill

That's all, folks ...
\end{document}

The document compiles to this:

test.png

I was basically trying to output the image first as a \llap (its \mbox construct [I guess] is taken from \llap (or \rlap) at the beginning of an indented paragraph), and then have the horizontal under-line via \hrulefill typeset over the image. That generally seems to work.

Then I was trying to position the image, so that its underline aligns with the \hrulefill. As How to shift graphics/adjust placement of figure with \includegraphics notes, \hspace* works here (\hfil unfortunately doesn't work, as the overlap \mbox apparently has to have width of 0pt) - and I'm pleased with the horizontal position.

The problem is the vertical position - how can I push the image "down", so its underline aligns with the \hrulefill one? Clearly \vspace* doesn't work (and using something like \rule{0pt}{2cm} moves all of the rows, while the relative vertical position between the image underline and the \hrulefill one does not change).

2
  • 1
    Did you try \raisebox?
    – egreg
    May 9, 2015 at 22:54
  • Thanks @egreg - nope, forgot completely about it :) will try it now...
    – sdaau
    May 9, 2015 at 22:54

1 Answer 1

12

Use \raisebox:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

Just testing something here... Lorem ipsum dolor sit amet,...

\noindent
Attempt at signature:
\makebox[0pt][l]{\hspace*{2cm}\raisebox{-3ex}{\includegraphics{testing.png}}}%
\hrulefill

That's all, folks ...
\end{document}

enter image description here

1
  • Many thanks for that, @egreg - that does the trick! Cheers!
    – sdaau
    May 9, 2015 at 23:08

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.