4

(28 May 2021 Update) This is almost solved. If David Purton, or anyone else, could help resolve the remaining TWO things, it would be fully answered:

-- enable height adjustment of the margin and its vertical lines to account for varying height of footnotes

-- keep surplus cross-references on the same page, adding them to the footnotes, instead of having them overflow to the next page

-- the superscripted letters linked to the cross-references shown in the answer by @DavidPurton are unnecessary; only need verse numbers for the references


I would really like to create a book with the same layout I see in the Bible pictured below, having two columns, a center margin with reference notes that correspond to the numbered verses in those columns, and a footnote at the bottom of the page of arbitrary length that will vary in length for each page depending on the amount of content in it. Some pages may have no footnote at all, some pages may be half footnote, etc. The center margin should always be of the same width regardless of content (even if it is empty and left blank), and it should be set apart by vertical lines as in the picture.

Two-column Bible with cross-references in center margin between them

Notice how the center margin's references come in the same order as the Bible verses, but are not tied to their verses in the same vertical position. In other words, the wrapping adjustment is done for them on a per-page basis. Below the bottom of the right-hand column some extra center-margin notes were placed in this image: Those could be wrapped in this same manner, or they could be moved to a footnote. For my purposes, I'm also content to have any spillover from the center margin like that excised, or reduce (and space) the content of the columns to match it.

Would this layout be possible with any of the packages currently available? If not, what would it take to make this possible, e.g. where can I go to learn how to create a package for LaTeX?

For reference, a similar question was asked a couple years ago, with a partial solution provided:

Two-column document with annotations between columns

That, however, still did not provide an actual center-column for references, it just spaced the columns apart and put the references beside them into that space. This means references from each column might collide, and would require manual spacing--simply not an acceptable solution. Also, no vertical lines were provided to set the center column apart.

NOTE: Any solution provided must be compatible with the polyglossia package and format, as this will be a multi-lingual document, including Asian script which does not ordinarily have word spaces to delimit words. Additionally, fancyhdr will add a further layer of complexity to the layout. I hope this does not all turn out to be a pipe dream.

Update (2 April 2020): As the answer posted below indicates several shortcomings with the method used, has anyone found a way to solve those? Obviously, the footnotes need to grow or shrink to accommodate the requirements on a page-by-page basis, with some pages not needing any at all--and the text height for the columns should yield space accordingly. The center margin also needs more flexibility, with a solution such as is indicated in the photo being ideal.

Update (27 April 2021): I'm still looking for a solution to incorporate both a center column for cross-references, and a footnote area for additional notations. In case it makes the project easier, each page could consist of three columns consisting of (1) Original Bible text, (2) Cross-references for that text, and (3) a translation of the text in another language. In this scenario, both the center and right-side columns would maintain alignment with the left-side column, table-style, which could greatly simplify things.

1 Answer 1

5

Here's my (partial) attempt.

I've used the memoir class which supports both sidebars and side footnotes. I found the sidebar slightly easier to set up to do this kind of thing, so I used it, rather than the more obvious side footnote.

The heavy lifting is done by some expl3 code which keeps track of verse numbers and cross reference numbers and adds things to the side bar.

Unfortunately it currently doesn't adjust the height of the sidebar and vertical lines to take account of changing text height with normal footnotes :(. The side bar also overflows on to the next page rather than the bottom of the second column.

I'll see if I can fix this, but it's late where I am. Or maybe someone else can offer a better solution.

\documentclass{memoir}

\usepackage{xparse}
\usepackage{microtype}
\usepackage{lettrine}
\usepackage{eso-pic}
\usepackage{multicol}

% set up ordinary footnotes
\makeatletter
\def\footnoterule{\kern-3\p@
  \hrule \@width \textwidth \kern 2.6\p@}
\makeatother
\renewcommand\thefootnote{\textit{\arabic{footnote}}}

% code to create chapters, verses, and cross references
\ExplSyntaxOn

\int_new:N \crossref_int
\int_new:N \vs_int
\tl_new:N \crossref_tl

% insert a cross reference
\NewDocumentCommand {\crossref} {m}
  {
    \int_compare:nNnT { \crossref_int } > { 25 }
      {
        \int_set:Nn \crossref_int { 0 }
      }
    \int_incr:N \crossref_int
    \textsuperscript{ \emph { \int_to_alph:n { \crossref_int } } }
    \tl_if_empty:NF \crossref_tl
      {
        \tl_gput_right:Nn \crossref_tl { ~ }
      }
    \tl_gput_right:Nx \crossref_tl
      {
        \exp_not:N \textsuperscript
          {
            \exp_not:N \emph { \int_to_alph:n { \crossref_int } }
          }
        \, #1
      }
  }

% insert chapter marker
\NewDocumentCommand {\ch} {m}
  {
    \int_gset:Nn \vs_int {1}
    \lettrine [findent=0.5em,nindent=0em] { #1 } {}
  }

% output cross references from previous verse and insert verse marker
\NewDocumentCommand {\vs} {m}
  {
    \tl_if_empty:NF \crossref_tl
      {
        \sidebar
          {
            \textbf { \int_use:N \vs_int } \, \tl_use:N \crossref_tl
          }
      }
    \int_gset:Nn \vs_int { #1 }
    \tl_gclear:N \crossref_tl
    \textsuperscript { #1 \, }
  }

% output any remaining cross references
\AtEndDocument
  {
    \tl_if_empty:NF \crossref_tl
      {
        \sidebar
          {
            \textbf { \int_use:N \vs_int } \, \tl_use:N \crossref_tl
          }
      }
  }

\ExplSyntaxOff

% set up centre column location and size
\setlength\columnsep{2.5cm}
\setlength{\sidebarhsep}{\dimexpr -0.5\textwidth - 0.5\columnsep + 2mm}
\setlength{\sidebarwidth}{\dimexpr \columnsep - 4mm}
\renewcommand{\sidebarfont}{\footnotesize\normalfont}
\renewcommand*{\sidebarform}{\raggedright\hangindent 1mm}
\setlength{\sidebarvsep}{0ex}
\setsidebarheight{\dimexpr \textheight - 1ex}

% add vertical lines
\AddToShipoutPictureBG{%
  \AtTextUpperLeft{%
      \hskip \dimexpr 0.5\textwidth - 0.5\columnsep + 1mm
      \vrule depth \dimexpr \textheight - \ht\strutbox - 1pt
      \hskip \dimexpr\columnsep - 2mm
      \vrule depth \dimexpr \textheight - \ht\strutbox - 1pt}}

\begin{document}

\begin{multicols}{2}
  \ch{1}\crossref{Gen.\ 1:1; [Col.\ 1:17; 1 John 1:1; Rev. 1:4, 8, 17; 3:14;
  21:6; 22:13]}In the beginning was \crossref{Rev.\ 19:13; [Heb.\ 4:12; 1 John
  1:1]}the Word, and \crossref{1 John 1:2; [ch.\ 17:5]}the Word was with God,
  and \crossref{Phil.\ 2:6}the Word was God. \vs{2}He was in the beginning
  with God. \vs{3}\crossref{ver.\ 10; Ps.\ 33:6; 1 Cor.\ 8:6; Col.\ 1:16;
  Heb.\ 1:2}All things were made through him, and without him was not any
  thing made that was made. \vs{4}\crossref{ch.\ 5:26; 11:25; 1 John 1:2;
  5:11}In him was life,\footnote{Or \emph{was not any thing made. That which
  has been made was life in him}} and \crossref{ch.\ 8:12; 9:5; 12:46}the life
  was the light of men.  \vs{5}\crossref{[ch.\ 3:19]}The light shines in the
  darkness, and the darkness has not overcome it.
\end{multicols}

\end{document}

MWE output

9
  • Are you programming with expl3 to do the "heavy lifting"? What exactly is that, and how could someone like me learn to use it? Do you think it is possible to adapt what you have here to resolve the issues you outlined?
    – Polyhat
    Feb 2, 2020 at 20:20
  • @Polyhat Sorry, "heavy lighting"is English idiom. It just means this is the hard part. Practically everything is possible in LaTeX, but time and knowledge of the underlying TeX concepts limit my abilities. I don't know if can do a complete solution or not. Feb 2, 2020 at 20:49
  • 1
    Variable names in exp3 code should be named \<scope>_<module>_<name>_<type>. <scope> is either l for local variables, g for global, and c for constants. <module> should be common between them and the macros you define. <name> is anything that identifies the variable. And <type> is tl for token list variables, int for integers, and so on. I'd change them to \int_new:N \l_polyhat_crossref_int \int_new:N \l_polyhat_vs_int \tl_new:N \l_polyhat_crossref_tl. Other than that, nice answer ;-) Feb 3, 2020 at 1:06
  • @PhelypeOleinik, yes I know this. But for proof of concept answers sometimes I don't bother. This answer isn't even remotely useful enough for a final solution. Feb 3, 2020 at 1:37
  • @DavidPurton No worries. It's just that I, as a full-time annoyance, am morally obliged to say that ;-) (also for future readers) Feb 3, 2020 at 1:49

You must log in to answer this question.

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