LaTeX forum ⇒ Document ClassesVertical alignment of minipages

Information and discussion about specific document classes and how to create your own document classes.
baslers
Posts: 4
Joined: Fri Mar 14, 2008 11:09 am

Vertical alignment of minipages

Postby baslers » Fri Mar 14, 2008 11:21 am

Hi,

I have two problems regarding vertical alignment of minipages inside a figure.

In the first example, I'm putting two minipages side-by-side, one containing a figure, the other one containing text. With either positioning parameter [t,b,c] for the minipage, I cannot get them to align vertically. What can I do about this?

\begin{figure}[!h]
\begin{minipage}[!t]{0.4\textwidth}
\includegraphics[width=1\textwidth]{Images/Assembly/Shaft_axis.jpg}
\caption{Shaft axis alignment}
\label{fig:shaft_axis}
\end{minipage}
\hspace{0.1\textwidth}
\begin{minipage}[!t]{0.5\textwidth}
blabla
\end{minipage}
\end{figure}

The same problem occurs when I try putting two figures side-by-side using minipages. Vertical alignment cannot be achieved.


\begin{figure}[!h]
\begin{minipage}[!b]{0.33\textwidth}
\centering
\includegraphics[width=0.9\textwidth]{Images/Embedding/embedded_funct_spine_unit.jpg}
\caption{Molded Functional Spine Unit}
\label{fig:embed_fsu}
\end{minipage}
\vspace{0pt}
\begin{minipage}[!b]{0.66\textwidth}
\centering
\raisebox{0.5cm}{\includegraphics[width=0.9\textwidth]{Images/Embedding/embedding_vertebrae.jpg}}
\caption{Molded Single Vertebra}
\label{fig:embed_vert}
\end{minipage}
\end{figure}

Any help would be much appreciated. Thanks!

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Juanjo
Posts: 656
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Fri Mar 14, 2008 11:52 am

The ! descriptor should go in the optional argument of float environments (table, figure), not in that of minipage. Does this solve your problem? If not, build a minimal example, attach the relevant files (so everybody can compile it) and say precisely how you would like to align the minipages.

Link:
BBcode:
HTML:
Hide post links
Show post links

baslers
Posts: 4
Joined: Fri Mar 14, 2008 11:09 am

Postby baslers » Fri Mar 14, 2008 12:41 pm

Thanks a lot. The problem with the two figures was already solved using your suggestion.

However, the example with the figure and the text next to it still does not work properly. I am attaching a .rar-file with a minimal example, the picture and a pdf of what I get when I compile it.

What I would like to achieve is that the top edge of the text next to the figure is vertically aligned with the top edge of the figure. Any suggestions on this?
Attachments
Minipages_vertical_alignment.rar
(96.78 KiB) Downloaded 1091 times

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Juanjo
Posts: 656
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Fri Mar 14, 2008 1:56 pm

Here is your code with a few changes in order to solve your problem and avoid warnings.

  1. \documentclass[a4paper,11pt,titlepage]{article}
  2.  
  3. % Packages included
  4. \usepackage{graphicx}
  5.  
  6. \listfiles
  7.  
  8. \begin{document}
  9.  
  10. \begin{figure}[!h]
  11. \begin{minipage}[t]{0.4\textwidth}
  12. \vspace{0pt}
  13. \includegraphics[width=\linewidth]{Gauge_adhesive_bonding.jpg}
  14. \caption{Adhesive bonding using gauge}
  15. \label{fig:gauge_adhesive_bonding}
  16. \end{minipage}
  17. \hfill
  18. \begin{minipage}[t]{0.5\textwidth}
  19. \vspace{0pt}\raggedright
  20. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  21. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  22. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  23. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  24. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  25. blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
  26. \end{minipage}
  27. \end{figure}
  28.  
  29. \end{document}

The tip is to add \vspace{0pt} at the beginning of every minipage, as suggested in page 37 of the epslatex document.

Link:
BBcode:
HTML:
Hide post links
Show post links

baslers
Posts: 4
Joined: Fri Mar 14, 2008 11:09 am

Postby baslers » Fri Mar 14, 2008 2:56 pm

Many thanks, also for the reference to the epsdocument. It seems very useful and your suggested adaptations to the code work perfectly!

Have a great day!

Link:
BBcode:
HTML:
Hide post links
Show post links

dimarcom
Posts: 26
Joined: Wed Mar 05, 2008 11:03 am

Postby dimarcom » Tue Apr 01, 2008 2:54 pm

Hi,

I tried your bit of code using TexnikCenter with pdfLatex on Windows, and it didn't work for me... my problem is (i think) simpler: i just try to get the warning symbol aligned with the fbox, but vspace{} and vspace*{} won't work... I tried many combinations of minipages and parbox, and i can't work it out.

Here's my bit of code:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{center}
\vspace*{1cm}
\includegraphics[height=2cm]{../latex_066/fig/pictossignalisationjpg/DangerGeneral.jpg}
\hspace{0.5cm}
\fbox{\fbox{\parbox{8cm}{
\begin{center}
{\sf{WARNING}}: \\
\end{center}
}}}
\end{center}

\end{document}

Thanks,
Marie.
Attachments
warning.JPG
warning.JPG (6.91 KiB) Viewed 92116 times

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Stefan Kottwitz
Site Admin
Posts: 7801
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Tue Apr 01, 2008 3:29 pm

Hi Marie,

you will get that alignment if you put the \includegraphics command inside a parbox:
  1. \parbox{WIDTH}{\includegraphics[height=2cm]{../latex_066/fig/pictossignalisationjpg/DangerGeneral.jpg}}


Btw. don't use \sf, \textsf would be the better choice.

Stefan

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Juanjo
Posts: 656
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Tue Apr 01, 2008 4:22 pm

This also works:
  1. \documentclass{article}
  2. \usepackage{graphicx}
  3.  
  4. \begin{document}
  5.  
  6. \includegraphics[height=2cm]{DangerGeneral.jpg}\hspace{2cm}
  7. \fbox{\fbox{\parbox[b][2cm][c]{8cm}{\centering\sffamily WARNING}}}
  8.  
  9. \end{document}

Link:
BBcode:
HTML:
Hide post links
Show post links

dimarcom
Posts: 26
Joined: Wed Mar 05, 2008 11:03 am

Postby dimarcom » Wed Apr 02, 2008 3:33 pm

thanks for the suggestions !

this didn't work (but thanks for the help anyways):
you will get that alignment if you put the \includegraphics command inside a parbox:
Code:
\parbox{WIDTH}{\includegraphics[height=2cm]{../latex_066/fig/pictossignalisationjpg/DangerGeneral.jpg}}

but this elegant simple code worked just fine:
Code:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[height=2cm]{DangerGeneral.jpg}\hspace{2cm}
\fbox{\fbox{\parbox[b][2cm][c]{8cm}{\centering\sffamily WARNING}}}
\end{document}

thanks again !!
marie.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Document Classes”

Who is online

Users browsing this forum: No registered users and 3 guests