76

I need to put some text at the same height in my page, and I'm trying to do it with a minipage, but I'm not able to do it since they get centre-aligned.

enter image description here

This is the LaTeX for the figure I've uploaded:

\begin{minipage}[]{0.5\textwidth}
    \begin{flushleft}
        {\large \textit{Author}:\vspace*{0.5cm} \\ 
        Me}
    \end{flushleft}
\end{minipage}%
%
\begin{minipage}[]{0.5\textwidth}
    \begin{flushright}
        {\large \textit{Supervisor}:\vspace*{0.5cm} \\ 
        Him}\\
        \vspace*{0.5cm}
        {\large \textit{Advisor}:\vspace*{0.5cm} \\ 
        Other Guy}
    \end{flushright}    
\end{minipage}%

Can you please explain me what I'm doing wrong?

David Carlisle
  • 757,742
Matteo
  • 1,787

2 Answers2

99

Use [t] as the option -- \begin{minipage}[t]{0.5\textwidth}:

\documentclass{article}
\begin{document}
  \begin{minipage}[t]{0.5\textwidth}
    \begin{flushleft}
        \large \textit{Author}:\vspace*{0.5cm} \\
        Me
    \end{flushleft}
\end{minipage}%
%
\begin{minipage}[t]{0.5\textwidth}
    \begin{flushright}
        \large \textit{Supervisor}:\vspace*{0.5cm} \\
        Him\\
        \vspace*{0.5cm}
        \large \textit{Advisor}:\vspace*{0.5cm} \\
        Other Guy
    \end{flushright}
\end{minipage}%
\end{document}

enter image description here

David Carlisle
  • 757,742
  • It was a really silly question...thks ;) – Matteo Nov 08 '12 at 16:21
  • If you use a command like \large always include a paragraph end (\par or blank line) before the } that closes the scope, I know the ones here are just copied from the MWE:-) In this case you could more simply not have the { } and just let the \large end naturally at the end of the flushright environment. – David Carlisle Nov 08 '12 at 19:16
  • 2
    @Matteo Nothing is silly here, once one doesn't know how to do something then it is important. It is after you see the solution that it becomes obvious. – azetina Nov 08 '12 at 19:20
  • @DavidCarlisle: You caught me. :-) I blindly copied and looked only at [t]. You are right. Thank you. :-) –  Nov 08 '12 at 22:21
  • @azetina - thks for your kindness, for sure the next time it will be silly... :) – Matteo Nov 09 '12 at 08:25
  • @DavidCarlisle - could you please explain me a little better the scope of your comment?I'm afraid I'm missing something. Thks in advance :) – Matteo Nov 09 '12 at 08:26
  • see the example here http://tex.stackexchange.com/questions/36454/inconsistent-line-spacing – David Carlisle Nov 09 '12 at 09:27
  • 3
    When I try this with two unequal height images, it does not work - it still aligns on the bottom. – hola Oct 18 '17 at 16:36
  • 34
    This didn't work for me. What did work is to be sure to set the [t] position indicator for each minipage, and then to specify \vspace{0pt} at the top of each minipage. Then the resulting minipages are all aligned at the top of each other. I found this solution here: https://latex.org/forum/viewtopic.php?t=1059 – jdods Mar 04 '19 at 04:10
  • @jdods you are right, same here. BUT conference want source files without any vspace or hspace commands. Any alternative ideas? – Christian Gold May 17 '21 at 13:04
  • 1
    @Christian Gold: an alternative is \mbox{}\\ – user4624500 Sep 13 '22 at 12:21
  • @jdods, thanks a lot, this is really a mystery to me why a \vspace{0pt} makes it work and what it really changes... – axkibe Feb 26 '24 at 10:53
25

Just to highlight the jdods user remark in the comments to David Carlisle's solution:

Although the solution given by user David Carlisle is fully functional for various cases, there are some cases because of the extra settings in the document, which do not allow to maintain the alignment, so the use of \ vspace {0pt} is a more complete solution but I believe it does not end for other possible deformations that could arise. The use of \ vspace {0pt} was pointed out by user jdods and therefore does not represent a response of my own. To do so, see https://latex.org/forum/viewtopic.php?t=1059 and consequently https://www.ctan.org/pkg/epslatex.

sample

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fancybox}
\usepackage{geometry}
\thispagestyle{empty}
\begin{document}
\centering    
With \verb|\vspace{0pt}| at the top of each minipage of this example of a pair of minipages see below: %
\\
\fbox{
        \begin{minipage}{0.8\linewidth}\vspace{0pt}%
        \fontsize{10}{6}\selectfont Reference.
    \end{minipage}%
    }%
        \fbox{%
        \begin{minipage}{0.1\linewidth}\vspace{0pt}%
        \fontsize{10}{6}\selectfont Reference.
            \end{minipage}
    }
        \end{document}