(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.
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.


expl3to 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 02 '20 at 20:20exp3code should be named\<scope>_<module>_<name>_<type>.<scope>is eitherlfor local variables,gfor global, andcfor constants.<module>should be common between them and the macros you define.<name>is anything that identifies the variable. And<type>istlfor token list variables,intfor 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 ;-) – Phelype Oleinik Feb 03 '20 at 01:06expl3is on a totally different wavelength. But the above code has some flaws: 1) the cross-references for the final verse of a chapter may be mis-attributed to the first verse of the following chapter; 2) there is currently no way to handle an overflow of the references, such as by placing them in the footnotes or at the bottom of the second text column. Fixable? I managed to solve the\vruleissues already. – Polyhat Jun 04 '21 at 09:27