3

I'm trying to create a notepad between two columns of text, where someone could write notes referencing either column of text. The code below has a section of text, followed by a section of two-column text (with the notepad between the columns), followed by a section of text. I used multicolrule because it seemed to be close to what I wanted.

There are several problems that I have been unable to figure out.

  1. If I add a SetMCRule command within the multicols section, there is a large space before the text in the multicol section starts printing. Also, it's printing beyond the end of the page, ignoring the end of page.

  2. The tikz code that prints the lines is hardcoded to a specific number of lines. It needs to be able to figure out exactly how many lines, and where to start the ruled section and where to stop it.

  3. Ideally, I would like to add a box (tcolorbox) to create a border for the notepad.

It's quite possible that the multicolrule package is not the best fit, so I'm open to better options.

Note: I'm using lualatex, but I have tried xelatex and there doesn't appear to be any difference.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[tikz]{multicolrule}[2019/10/01]
\usepackage{lipsum}
\usepackage{xcolor}
\usetikzlibrary{calc}
\setlength{\columnsep}{24pt}
\setlength{\columnseprule}{.5pt}
\definecolor{notepadrule}{RGB}{217,244,244}

\begin{document}
\lipsum[1-2]

\setlength{\columnsep}{2in}
\begin{multicols}{2}
\SetMCRule{color=gray,width=0.4pt, expand=2pt, custom-line={
    \foreach \fila in {0,...,20}
    {
      \draw [line width=2pt,color=notepadrule]
        (current page.west|-0,-\fila*16pt) -- ++(0.90\columnsep,0);
    }
}}
\lipsum[3-7]
\end{multicols}

\setlength{\columnsep}{24pt}
\lipsum[1-2]
\end{document}
2
  • Welcome to SE. Are you looking for an image that extends the full height of each column, regardless of that column's height, or are you looking to specify a specific number of lines for for the notepad?
    – Karl Hagen
    Commented Dec 30, 2019 at 19:44
  • Think of it as a lined piece of paper that horizontally spans the columnsep space, and vertically that starts at the beginning of the multicols, and ends at the end of the multicols. Does that make sense?
    – Bart Wise
    Commented Dec 30, 2019 at 19:59

1 Answer 1

1

Is this along the lines of what you want? Note that the coordinate system within multicolrule's custom line is set so that y=0 is at the bottom of the column. Your negative expression -\fila*16pt therefore drew in the wrong direction, which is why the image pushed off the page.

This solution uses the (TOP) and (BOT) coordinates that multicolrule predefines for use in custom lines, so it will size appropriately to the column height. I've also added the requested box around the horizontal lines.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[tikz]{multicolrule}[2019/10/01]
\usepackage{lipsum}
\usepackage{xcolor}
\usetikzlibrary{math,calc}
\setlength{\columnsep}{24pt}
\setlength{\columnseprule}{.5pt}
\definecolor{notepadrule}{RGB}{217,244,244}

\begin{document}
\lipsum[1-2]

\setlength{\columnsep}{2in}
\begin{multicols}{2}
\SetMCRule{width=0.4pt, custom-line={
    \tikzmath {coordinate \t, \b;
      \t = (TOP)-(.45\columnsep,1pt);
      \b = (BOT)+(.45\columnsep,-1pt);
      integer \r;
      \r = \ty / 16;
    }
    \draw [line width=2pt,color=notepadrule]
    (\t) -- ++(.9\columnsep,0) -- (\b) -- ++(-.9\columnsep,0) -- cycle;
    \foreach \fila in {1,...,\r}
    {
      \draw [line width=2pt,color=notepadrule]
        ($(\t)-(0,\fila*16pt)$) -- ++(0.90\columnsep,0);
    }
}}
\lipsum[3-7]
\end{multicols}

\setlength{\columnsep}{24pt}
\lipsum[1-2]
\end{document}

One limitation is that the lines are always a fixed distance and the bounding box uses the full column height, so you can have an awkward looking gap between the last horizontal line and the lower line of the bounding box, as on the second page of this MWE:

enter image description here

There are a variety of solutions to this, depending on how you want it to look. For example, you could size the bounding box to an integer number of these lines, but I haven't tried anything fancy since I'm unsure what your desired effect is.

Edit: Replace the \SetMCRule definition above with this version and you will get an integer number of lines:

\SetMCRule{width=0.4pt, custom-line={
    \tikzmath {coordinate \t, \b;
      \t = (TOP)-(.45\columnsep,0);
      integer \r, \s;
      \r = \ty / 16;
      \s = \ty - \r*16;
      \t = (\t)-(0,.5*\s);
      \b = (\t)+(.9\columnsep,-\r*16);
    }
    \draw [line width=2pt,color=notepadrule]
    (\t) -- ++(.9\columnsep,0) -- (\b) -- ++(-.9\columnsep,0) -- cycle;
    \foreach \fila in {1,...,\r}
    {
      \draw [line width=2pt,color=notepadrule]
      ($(\t)-(0,\fila*16pt)$) -- ++(0.90\columnsep,0);
    }
}}

Edit 2: bug fix to the second version. Image should be correctly centered vertically now.

3
  • This is great. And yes, ideally, your suggestion in sizing the bounding box to an integer number of lines would be perfect.
    – Bart Wise
    Commented Dec 30, 2019 at 22:07
  • See the updated answer above
    – Karl Hagen
    Commented Dec 30, 2019 at 22:26
  • Awesome! Thanks!
    – Bart Wise
    Commented Dec 30, 2019 at 23:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .