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
General ⇒ Vertical alignment - pictures in tex
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Vertical alignment - pictures in tex
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
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
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
-
- Posts: 6
- Joined: Sun Jun 01, 2008 2:34 pm
Vertical alignment - pictures in tex
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
I used pdflatex to compile the file.
Thanks again
Pere
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}
Thanks again
Pere
- Attachments
-
- dummy.pdf
- (913 Bytes) Downloaded 189 times
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Vertical alignment - pictures in tex
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.
I guess this will help. Using an external graphics file, you would have to include it as follows.
The minipage environment is automatically centered to the running text if not given any other option(s).
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.\medskipThis black box \begin{minipage}{11pt}\rule{11pt}{11pt}\end{minipage} is now vertically centered.\end{document}
Code: Select all
This small graphic \begin{minipage}{11pt}\includegraphics[width=11pt]{dummy}\end{minipage} is now vertically centered.
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
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
-
- Posts: 6
- Joined: Sun Jun 01, 2008 2:34 pm
Re: Vertical alignment - pictures in tex
Great. Thank you very much.