3

Hi I am writing a two column document in exam class. I want to split the vertical ruler between the columns and add a text in the gap. How can I do that ? (The red text in the MWE should be placed in the ruler gap.)

enter image description here

The code to generate this MWE is:

\documentclass[11pt]{exam}
\usepackage{lipsum}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgf}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{color}
\usepackage{mdframed}
\usepackage[top=1in, bottom=1.25in, left=0.8in, right=0.8in]{geometry}
\footer{}{\thepage}{}
\usepackage{graphicx}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\setlength{\multicolsep}{1.2cm}
\usepackage{wrapfig}
\setlength{\columnseprule}{0.5pt}
\makeatletter
\def\columnseprulecolor{%                                                                                                                                                                              
\rotatebox{90}{\makebox[\@colroom][c]{\color{red}{\mbox{Text Here}}}}
    }%                                                                                                                                                                                                 
\makeatother

\begin{document}
\begin{multicols}{2}
\lipsum[1-10]
\end{multicols}
\end{document}

Thank you in advance, cheers.

3

Here is a tikz based solution that is basically modification of my previous answer to a similar request:

\documentclass[11pt]{exam}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage[top=1in, bottom=1.25in, left=0.8in, right=0.8in]{geometry}
\footer{}{\thepage}{}
\setlength{\columnsep}{1cm}
\setlength{\multicolsep}{1.2cm}

\usepackage{tikz}
\makeatletter
\def\columnseprulecolor{\vrule%
\rotatebox{90}{\makebox[\ht\mult@rightbox][c]{\begin{tikzpicture}[remember picture,overlay]\node[fill=white,text=red]{Some text};
\end{tikzpicture}}}
    }%
\makeatother

\begin{document}
\begin{multicols}{2}
\lipsum[1-10]
\end{multicols}
\end{document}

In order to turn the direction of the red text by 180° you can add the option rotate=180 as follows: \node[fill=white,text=red,rotate=180]{Some text}.


If you want to continue the separator line all the way to the bottom of the page even if the text does not fill the whole page, you might be interested in the following modification of David Carlisle's answer:

\documentclass[twocolumn]{exam}
\usepackage{xcolor}
\usepackage{lipsum}
\setlength\columnsep{40pt}
\usepackage{graphicx}
\def\columnseprule{0pt\relax
\makebox[0pt]{%
\rotatebox{90}{\makebox[\textheight]{\hrulefill\mbox{%
\rule[-10pt]{0pt}{20pt}%
\raisebox{-2pt}{\enspace\textcolor{red}{Something}\enspace}% %<---------------
}\hrulefill}}\kern.4pt}}
\begin{document}
\lipsum
\lipsum[1-2]
\end{document}

In case you also want to rotate the text by 180°, you can replace the marked line by the following: \rotatebox{180}{\raisebox{-2pt}{\enspace\textcolor{red}{Something}\enspace}}%

  • Thank you, this is exactly what I am looking for. I did not think I would need Tikz. But out of curiosity, is there any way to rotate the result by 180 degrees ? The way it produce the text is downside to upside. Can I make it the other way around ? – user175924 Jun 11 '18 at 17:30
  • 1
    @user175924: Maybe not the most elegant solution, but to rotate the text, you could use \node[fill=white,text=red,rotate=180]{Some text} where I have added the rotate=180 option. – leandriis Jun 11 '18 at 18:19
  • For the sake of completeness, could you suggest any solution if I want to stretch the \vrule all along the page, instead of limiting its length with the content of the page ? – user175924 Jun 11 '18 at 22:05
  • @user175924: I have edited my anser to also include such a possibility. Instead of using multicols this solution is based on the twocolumn mode of the exam class. – leandriis Jun 12 '18 at 9:44

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.