2

The vertical alignment of one-line text in minipages depends on the vertical extent of the text itself:

\documentclass{scrartcl}
\begin{document}
  bad alignment:
  \frame{
  \begin{minipage}[c][1cm][c]{0.1\linewidth}
    \LARGE Good
  \end{minipage}}
  \frame{
  \begin{minipage}[c][1cm][c]{0.2\linewidth}
     \LARGE Morning
  \end{minipage}}
\end{document}

bad alignment

There is a simple solution adding a full extent dummy symbol like \ddag, but I don't like this solution for different reasons (e.g. bad for people who want to copy the text from my pdf as they will copy my hidden dummy symbol as well):

\documentclass{scrartcl}
\usepackage{color}
\begin{document}
  dummy symbol solution:
  \frame{
  \begin{minipage}[c][1cm][c]{0.1\linewidth}
    \LARGE Good\textcolor{white}{\ddag}
  \end{minipage}}
  \frame{
  \begin{minipage}[c][1cm][c]{0.2\linewidth}
    \LARGE Morning\textcolor{white}{\ddag}
  \end{minipage}}
\end{document}

enter image description here

Do you have any advices how to solve this problem?

  • 2
    Usually in such cases what I does is to add \vphantom{g} in the definition of \end{...}. This will be a problem when we use boxes. – Jagath Jul 15 '13 at 13:28
  • 1
    Use \strut instead of a whitened character. However, \frame is an undocumented macro and probably you should use \fbox – egreg Jul 15 '13 at 13:46
  • @Jagath : Thanks for this comment. Could you explain it a little more in detail, maybe as an answer? For example: 1st. I didn't redefine \end before. 2nd. I didn't use \vphantom before - doesn't it leave a hidden symbol which I can copy as well? – matheburg Jul 15 '13 at 13:47
  • 2
    @JohnWickerson Those optional arguments are not very much known, but they are legal and useful. – egreg Jul 15 '13 at 13:53
  • 1
    @JohnWickerson : Take a look e.g. here. – matheburg Jul 15 '13 at 13:54
6

I don't know about the \frame{...} command you're using, but it seems that \fbox{...} is the one you want for this purpose: it makes the baseline of its contents respect the baseline of its environment.

Also, as Jagath AR has suggested, you can use \vphantom{...} rather than white text. Simpler still, you can use \strut.

\documentclass{article}
\begin{document}
\noindent 
  With struts:
  \fbox{
  \begin{minipage}[t]{16mm}
    \LARGE Good\strut
  \end{minipage}}
  \fbox{
  \begin{minipage}[t]{23mm}
    \LARGE Morning\strut
  \end{minipage}}
  Without struts:
  \fbox{
  \begin{minipage}[t]{16mm}
    \LARGE Good
  \end{minipage}}
  \fbox{
  \begin{minipage}[t]{23mm}
    \LARGE Morning
  \end{minipage}}
\end{document}

enter image description here

  • 1
    Thank you - this is the beautiful solution I was looking for! Nevertheless, the extended minipage options would make your solution looking much better ;-) – matheburg Jul 15 '13 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.