简体   繁体   English

使用 minipage 时日期水平对齐的问题

[英]Issues with horizontal alignment of date when using minipage

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.我使用minipage环境将老师的姓名、日期、开始时间和持续时间放在同一行。 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:结果是:

结果

How could I solve the problem?我该如何解决这个问题?

You can bottom-align the minipages:您可以底部对齐 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:结果: 显示预期效果的编译结果

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:您可以通过向它们添加\strut来确保所有字段具有相同的高度:

\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} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM