# Horizontal equal spacing of minipages

This:

\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\rule[0.5em]{13em}{0.5pt}\\
%Text
\end{flushleft}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{flushleft} \large
\rule[0.5em]{13em}{0.5pt}\\
%Text
\end{flushleft}
\end{minipage}\\[3cm]


produces:

Whereas, what I need is this: ... where the red zones are equally sized blank spaces and the grey zones are the margins.

How do I go about doing this?

• No need for flushleft. You can use \raggedright. – Werner Mar 9 '17 at 2:36

## 1 Answer

You will need some \hfills to stretch out the content equally:

\documentclass{article}

\usepackage{showframe}

\begin{document}

\noindent
\mbox{}% Left margin marker
\hfill% Horizontal stretch
\begin{minipage}{0.3\textwidth}
\rule[0.5em]{\linewidth}{0.5pt}

%Text
\end{minipage}%
\hfill% Horizontal stretch
\begin{minipage}{0.3\textwidth}
\rule[0.5em]{\linewidth}{0.5pt}

%Text
\end{minipage}%
\hfill% Horizontal stretch
\mbox{}% Right margin marker

\end{document}


Of course, an even spread with visible space on either side of the minipages only works if the minipage widths don't take up the entire \textwidth. That is the case in your example, since .5\textwidth + .5\textwidth = \textwidth. I've reduced that to .3\textwidth each to show the effect of spreading.

• Thanks, it looks much better now. However, only the middle \hfill seems to be having effect, as the minipages cling to the margins at each end, regardless of whether I keep \noindent or not. Any insights regarding this? – Slaiyer Mar 9 '17 at 4:21
• @Slaiyer: What are the widths of the minipages? – Werner Mar 9 '17 at 6:49
• 0.4\textwidth each – Slaiyer Mar 9 '17 at 7:26
• @Slaiyer: Could you provide code that shows this? I can't seem to replicate it. Either here (as an edit to your post) or as a paste on Pastebin.com. – Werner Mar 9 '17 at 7:51
• @Slaiyer no, all the hfill will stretch equally, use \dotfill while debugging so you can see where the glue is being added. – David Carlisle Mar 9 '17 at 7:57