两个 `minipage` 里面的命令

两个 `minipage` 里面的命令

我想要两个minipages并排的。我可以轻松做到这一点。但是我想将其变成一个命令,并且它们minipages不再对齐,即使代码看起来相同。

问题

出了什么问题?在 MWE 中,我无需命令即可显示我想要的内容,然后尝试将其放入命令中。

\documentclass{article}

\newcommand{\dualminipage}[2][]
{
\begin{minipage}[t][][t]{0.45\linewidth}
#1
\end{minipage}\hfill
\begin{minipage}[t][][t]{0.45\linewidth}
#2
\end{minipage}
}

\begin{document}
% Firstly the minipages put simply.
\begin{minipage}[t][][t]{0.45\linewidth}
This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. 
\end{minipage}\hfill
\begin{minipage}[t][][t]{0.45\linewidth}
This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. 
\end{minipage}

\vspace{0.5in}
% Now the minipages put into a command

\dualminipage {
This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. This is the left-hand side. 
}
{
This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. This is the right-hand side. 
}
\end{document}

答案1

尝试

\newcommand{\dualminipage}[2]
{
\begin{minipage}[t]{0.45\linewidth}#1\end{minipage}
\hfill
\begin{minipage}[t]{0.45\linewidth}#2\end{minipage}
}

看来您\dualminipage定义中的第二个方框出现了问题。

相关内容