0

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

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.

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.