Issues with horizontal alignment of date when using minipage

1.9k Views Asked by At

I'm trying to create a test for my students. I put the teacher's name, date, start time and duration time on the same line using the minipage environment. I don't know why the date field is not aligned with the other fields. If I write anything other than the date, the text lines up perfectly.

The code I am using in overleaf is:

\documentclass[paper=a4, fontsize=10pt]{scrartcl} 

\usepackage[T1]{fontenc} 
\usepackage{times} 
\usepackage[brazil]{babel} 
\usepackage{amsmath,amsfonts,amsthm}
\usepackage[utf8]{inputenc}      
\usepackage{ae}                        
\usepackage{times}

\usepackage[american voltages, american currents]{circuitikz}
\ctikzset{bipoles/length=2.5em}
\usepackage{anysize}
\marginsize{2cm}{2cm}{1cm}{1cm}
\usepackage{caption}
%\usepackage{columns}

\begin{document}

\begin{minipage}{0.3\textwidth}
 Teacher: Guilherme 
\end{minipage}
  \begin{minipage}{0.2\textwidth}
  Date: 22/06/2022
\end{minipage}
  \begin{minipage}{0.15\textwidth}
  Start: 19:00
\end{minipage}
\begin{minipage}{0.2\textwidth}
  Duration: 120 min
\end{minipage}

\vspace{1.5cm}

\begin{minipage}{0.5\textwidth}
  Student:\underline{\hspace{7cm}}
\end{minipage}
    
\end{document} 

The result is:

Result

How could I solve the problem?

2

There are 2 best solutions below

0
On BEST ANSWER

You can bottom-align the minipages:

\begin{minipage}[b]{0.3\textwidth}
 Teacher: Guilherme 
\end{minipage}
  \begin{minipage}[b]{0.2\textwidth}
  Date: 22/06/2022
\end{minipage}
  \begin{minipage}[b]{0.15\textwidth}
  Start: 19:00
\end{minipage}
\begin{minipage}[b]{0.2\textwidth}
  Duration: 120 min
\end{minipage}

Result: Compiled result showing desired effect

0
On

The reason for the different alignment of the date are the / signs which go a bit below the baseline. You can make sure that all your fields have the same height by adding \strut to them:

\documentclass[paper=a4, fontsize=10pt]{scrartcl} 

\usepackage[T1]{fontenc} 
\usepackage{times} 
\usepackage[brazil]{babel} 
\usepackage{amsmath,amsfonts,amsthm}
\usepackage[utf8]{inputenc}      
\usepackage{ae}                        
\usepackage{times}

\usepackage[american voltages, american currents]{circuitikz}
\ctikzset{bipoles/length=2.5em}
\usepackage{anysize}
\marginsize{2cm}{2cm}{1cm}{1cm}
\usepackage{caption}
%\usepackage{columns}

\begin{document}

\begin{minipage}{0.3\textwidth}
 Teacher: Guilherme\strut
\end{minipage}
  \begin{minipage}{0.2\textwidth}
  Date: 22/06/2022\strut
\end{minipage}
  \begin{minipage}{0.15\textwidth}
  Start: 19:00\strut
\end{minipage}
\begin{minipage}{0.2\textwidth}
  Duration: 120 min\strut
\end{minipage}

\vspace{1.5cm}

\begin{minipage}{0.5\textwidth}
  Student:\underline{\hspace{7cm}}
\end{minipage}
    
\end{document}