0

How to put in two columns mode verbatim (block) text with vertical line in framed box, in figure.

The problem is that when the two columns are put in frame the vertical line disappears

\documentclass{book}
\usepackage{framed}
\usepackage{multicol}
\begin{document}    
\begin{figure}
\begin{framed}
\begin{multicols}{2}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.4pt}
\begin{verbatim}
first column
\end{verbatim}
\columnbreak
\begin{verbatim}
second column
\end{verbatim}
\caption{6-7}
\label{fig:06_07}
\end{multicols}
\end{framed}
\end{figure}
\end{document}
1

Do you accept a sidebyside tcolorbox instead of multicol and framed?

\documentclass{book}
\usepackage{tcolorbox}
\begin{document}    
\begin{figure}
\begin{tcolorbox}[sidebyside]
\begin{verbatim}
first column
\end{verbatim}
\tcblower
\begin{verbatim}
second column
\end{verbatim}
\end{tcolorbox}
\caption{6-7}
\label{fig:06_07}
\end{figure}
\end{document}

enter image description here

This is just the default solution. It's possible to produce solid vertical line, sharp corner, different colors for left and right columns, different width, ...

  • Thanks @Ignasi, the desired settings are \begin{tcolorbox} [sidebyside, colback=white, sharp corners, enhanced, segmentation style=solid] – ivand58 Jan 24 '18 at 21:35
  • Yes. Good work! – Ignasi Jan 24 '18 at 22:17

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.