Featured Book

LaTeX Beginners Guide

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 4 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Vertical alignment of minipages

Add tags Information and discussion about specific document classes and how to create your own document classes.

Vertical alignment of minipages

Postby baslers on Fri Mar 14th, 2008

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!
baslers
 
Posts: 4
Joined: Fri Mar 14th, 2008

Re: Vertical alignment of minipages

Postby Juanjo on Fri Mar 14th, 2008

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.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

Re: Vertical alignment of minipages

Postby baslers on Fri Mar 14th, 2008

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 825 times
baslers
 
Posts: 4
Joined: Fri Mar 14th, 2008

Re: Vertical alignment of minipages

Postby Juanjo on Fri Mar 14th, 2008

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

Code: Select all  •  Open in writeLaTeX
\documentclass[a4paper,11pt,titlepage]{article}

% Packages included
\usepackage{graphicx}

\listfiles

\begin{document}

\begin{figure}[!h]
   \begin{minipage}[t]{0.4\textwidth}
      \vspace{0pt}
      \includegraphics[width=\linewidth]{Gauge_adhesive_bonding.jpg}
      \caption{Adhesive bonding using gauge}
      \label{fig:gauge_adhesive_bonding}
   \end{minipage}
   \hfill
   \begin{minipage}[t]{0.5\textwidth}
      \vspace{0pt}\raggedright
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
      blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla
   \end{minipage}
\end{figure}    
                               
\end{document
}

The tip is to add \vspace{0pt} at the beginning of every minipage, as suggested in page 37 of the epslatex document.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

Re: Vertical alignment of minipages

Postby baslers on Fri Mar 14th, 2008

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!
baslers
 
Posts: 4
Joined: Fri Mar 14th, 2008

Re: Vertical alignment of minipages

Postby dimarcom on Tue Apr 1st, 2008

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 70918 times
dimarcom
 
Posts: 26
Joined: Wed Mar 5th, 2008

Re: Vertical alignment of minipages

Postby Stefan_K on Tue Apr 1st, 2008

Hi Marie,

you will get that alignment if you put the \includegraphics command inside a parbox:
Code: Select all  •  Open in writeLaTeX
\parbox{WIDTH}{\includegraphics[height=2cm]{../latex_066/fig/pictossignalisationjpg/DangerGeneral.jpg}}


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

Stefan
User avatar
Stefan_K
Site Admin
 
Posts: 6418
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Vertical alignment of minipages

Postby Juanjo on Tue Apr 1st, 2008

This also works:
Code: Select all  •  Open in writeLaTeX
\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
}
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007

Re: Vertical alignment of minipages

Postby dimarcom on Wed Apr 2nd, 2008

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.
dimarcom
 
Posts: 26
Joined: Wed Mar 5th, 2008


Return to Document Classes

Who is online

Users browsing this forum: No registered users and 4 guests