30

right now I have a latex section that looks like

\begin{minipage}{0.35\textwidth}   %left column
...
\end{minipage}
\hfill
\begin{minipage}{0.55\textwidth} %right column
...
\end{minipage}

This makes a nice looking two column layout, but I would like to add a vertical bar between the two minipages (where I currently have \hfill). What is the easiest way to do this?

David
  • 757
  • 1
  • 7
  • 17

2 Answers2

56

Using

\begin{minipage}{0.35\textwidth}   %left column

...

\end{minipage}

\hfill\vline\hfill

\begin{minipage}{0.55\textwidth} %right column

...

\end{minipage}

Works without needing to change to parbox and staying with minipage.

JCollerton
  • 3,227
  • 2
  • 20
  • 25
  • 6
    When doing this, I have to make sure that there are no empty lines between the `\end{minipage}` and `\hfill\vline\hfill` and then `\begin{minipage}` – FilBot3 Jun 30 '20 at 00:31
6

If using minipage is not a necessity for you, you could easily use the tabular environment together with parbox to achieve the desired result:

\begin{tabular}{l | l}
\parbox{0.35\textwidth}{
left column content
}
&
\parbox{0.35\textwidth}{
right column content
}
\end{tabular}
Miguel
  • 7,497
  • 2
  • 27
  • 46
  • 2
    For this it would be better to use a `p{}` column specification rather than `l` followed by a `\parbox`. – Werner Aug 13 '15 at 15:10