GeneralVertical alignment - pictures in tex

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Pere Callahan
Posts: 6
Joined: Sun Jun 01, 2008 2:34 pm

Vertical alignment - pictures in tex

Post by Pere Callahan »

Hi,

I hope you can help me with a tiny alignment problem. I want to use small pictures in my text, and used includegraphics{} to dot hat. So far so good, but the pictures are slightly larger than the text and I want the middle of the pictures to be aligned witht he the middle of the text - currently the bottoms of pictures and text are on the same height.. I imagine there is a short way to fix this but I don't know it.
Thanks for any help
Pere

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Vertical alignment - pictures in tex

Post by localghost »

Giving specific help would be much easier when having a minimal working example (MWE) that shows the undesired effect. If necessary, you additionally have to post the affected graphics file in the attachment here. The better way would be to place a dummy instead of the graphics file so the MWE would be compilable on every machine.


Best regards and welcome aboard
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Pere Callahan
Posts: 6
Joined: Sun Jun 01, 2008 2:34 pm

Vertical alignment - pictures in tex

Post by Pere Callahan »

Thanks for your answer, localghost.
I don't know how to use a dummy graphic so I attached one.
Here is the code for the MWE

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
I would like this black box \includegraphics{dummy} to be vertically centered.
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I used pdflatex to compile the file.

Thanks again

Pere
Attachments
dummy.pdf
(913 Bytes) Downloaded 189 times
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Vertical alignment - pictures in tex

Post by localghost »

Ah, now I see what you mean. Put the graphics into a minipage environment with a width that corresponds to that of the graphics. I worked out a small example.

Code: Select all

Code, edit and compile here:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{txfonts} % Additional font package
\parindent0em
\begin{document}
I would like this black box \rule{11pt}{11pt} to be vertically centered.
\medskip
This black box \begin{minipage}{11pt}\rule{11pt}{11pt}\end{minipage} is now vertically centered.
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I guess this will help. Using an external graphics file, you would have to include it as follows.

Code: Select all

This small graphic \begin{minipage}{11pt}\includegraphics[width=11pt]{dummy}\end{minipage} is now vertically centered.
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The minipage environment is automatically centered to the running text if not given any other option(s).
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Pere Callahan
Posts: 6
Joined: Sun Jun 01, 2008 2:34 pm

Re: Vertical alignment - pictures in tex

Post by Pere Callahan »

Great. Thank you very much.
Post Reply