Two `minipage` inside command

1,376

Try

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

It seems that second square backed in your\dualminipage definition make a problem.

Share:
1,376
Tim
Author by

Tim

Updated on November 17, 2020

Comments

  • Tim
    Tim almost 3 years

    I want two minipages side-by-side. I can do this easily. But then I want to turn it into a command, and the minipages don't line up any more, even thought the code looks identical.

    problem

    What is wrong? In the MWE i show what I want without the command, and then try to put it into command.

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