0

I am seeking a method to format a document in two columns, including both the body and the bibliography reference list at the end. My current workflow uses markdown columns within the body correctly, however the bibliography list is always formatted in single column. The document source is markdown, the bibliography is using the "citeproc" option on the pandoc command-line, pulling from an external bibtex file.

Here are my pandoc command line options in a windows cmd file:

`pandoc ^
 -f markdown bib-2cols.md ^
 --citeproc -M reference-section-title=References ^
 --bibliography refs.bib ^
 --lua-filter=filters/columns.lua ^
 -o bib-2cols.pdf`

However, this scheme results in the bibliography always having single column formatting: screenshot-pdf-output-bibliography-single-column

Toolchain is based on https://github.com/dialoa/columns v1.1.3, pandoc 3.1.2, on Windows 10.

Perhaps a solution could be by using some citeproc alternative bibliography processing method? Perhaps adding some inline TeX magic within the markdown? Perhaps using pandoc to generate TeX output rather than directly PDF, then using a TeX post-processing method?

I am interested to hear if anyone has found a way to create the two-column reference layout.

Related question: https://stackoverflow.com/questions/71780314/pandoc-md-to-docx-sections-with-different-number-of-columns

Annex: markdown source:

---
title: Bibliography Two Column Test

# Formatting:
geometry: "a4paper, left=2.0cm, right=2.0cm, top=1.9cm, bottom=2.54cm"

---
<!--- (start of two-column formatting) --->
::: columns

# Body{.unnumbered}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua.
 Consequat interdum varius sit amet mattis vulputate.
 Tincidunt id aliquet risus feugiat. Maecenas sed enim ut sem. 
 
In nibh mauris cursus mattis molestie a. Dictum fusce ut placerat orci nulla pellentesque.
 Tempus quam pellentesque nec nam. Sed elementum tempus egestas sed sed risus.
 Ipsum dolor sit amet consectetur adipiscing elit duis tristique sollicitudin.
 Interdum velit laoreet id donec ultrices tincidunt arcu non sodales.

## Place-Holder Citations to force inclusion until used within body:
### Papers

  [@jianming2017;
   @piponi2000;
   @armi2019;
   @walshaw1995;
   @xu2011;
   @wei2004;
   @vanwaveren2006;
   @maggiordomo2021;
   @maggiordomo2020;
   @zhang2020;
   @czachurski2022;
   @gal2010;
   @norynchak2021]

:::
<!--- closing columns --->
<!--- References Added below by citeproc --->
7
  • Hi, without seeing a MWE its hard to debugg what may cause the issue. Nevertheless, I posted an answer which works for me. See below
    – lukeflo
    Sep 14, 2023 at 8:30
  • As suggested in my answer, insert the yaml lines classoption ... below your yaml line title: ... (or above). Then remove your column divs ::: columns and the corresponding ::: at the end. With the ::: refs div at the end of my example you can explicitly print the references. The \clearpage is a optional LaTeX command to start the bibliography on a new page.
    – lukeflo
    Sep 14, 2023 at 9:07
  • If ::: columns is removed, is it still possible to override two-columns in the body, such as for a large table, or the abstract?
    – t3dr
    Sep 14, 2023 at 10:27
  • Yes it is, but AFAIK not just with simple pandoc commands. You need to adjust some of the LaTeX macros pandoc uses. Thats of course possible even in a markdown file, but you have to use plain LaTeX to adjust these setting. You would need to redefine some LaTeX macros inside the yaml header using the block-headings variable. Just look in the docs. I would not recommend that, because you would have to use many LaTeX commands inside your md file and you'll run into lots of errors as pandoc not always compiles every LaTeX code correct.
    – lukeflo
    Sep 14, 2023 at 11:20
  • If you're looking to produce such complex documents, IMHO you should directly use LaTeX. pandoc is better suited to create simple but good looking documents through LaTeX. Or you look out for a sophisticated pandoc template which offers your wishes...
    – lukeflo
    Sep 14, 2023 at 11:22

2 Answers 2

1

The obvious solution is to add the wanted informations to the yaml header of your .md file. Just add the following lines at the very top of your markdown file:

---
classoption:
- twocolumn
---

If you then process your document using pandoc it produces a full two-column document, where every page inlcuding the bibliography is formatted with two columns.

I use pandoc -s -C --csl=apa.csl test.md -o test.pdf

With a document like the following ...

---
classoption:
- twocolumn
author: Petra Digging
bibliography: [mybib.bib]
---

# A First Heading

Here ist some research text. Right now, its not very long, so go out and do some more research. Some more text to come. @doe_2022 @dane_2020

And, finally, a new paragraph.

* A list
* Second items

\clearpage

:::refs
:::

... it looks like that:

enter image description here

1
  • Confirmed this method works, and solves the issue as stated in the question title and initial question statement. Many thanks @lukflo!
    – t3dr
    Sep 17, 2023 at 14:41
2

Here is a further variation on the answer which allows column control over sections within the body of the document, as well as the reference bibliography using Markdown and Pandoc. This avoids unintended page breaks. Rather than using classoption to set two-column for the entire document, set it to single column default and then explicitly control columns using the LUA filter.

The method uses BOTH YAML classoption: - onecolumn and columns LUA filter.

Technique details:

  1. Include the following within the pandoc YAML header:

    ---
    classoption:
        - onecolumn
    ---
    
  2. Reference columns.lua on the pandoc command-line:

    --lua-filter=filters/columns.lua
    
  3. Use columns controls around content in the document body:

    ::: columns
    Two-column content here...
    :::
    One-column content here...
    
    
  4. At the very last line of markdown, add mode for bibliography:

    \twocolumn
    

Here is the re-worked example MD:

---
title: Bibliography Two Column Test

# use Tex built-in column control, covering bibliography, set to single column
classoption:
    - onecolumn

bibliography: [refs.bib]

# Formatting:
geometry: "a4paper, left=2.0cm, right=2.0cm, top=1.9cm, bottom=2.54cm"
---
<!--- (start of two-column formatting, using LUA filter  https://github.com/dialoa/columns, only within body) --->
::: columns

# Body
Two-column content here: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua.
 Consequat interdum varius sit amet mattis vulputate.
 Tincidunt id aliquet risus feugiat. Maecenas sed enim ut sem. 
 
:::

# More
Reverting to single column here: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua.
 Consequat interdum varius sit amet mattis vulputate.
 Tincidunt id aliquet risus feugiat. Maecenas sed enim ut sem. 

::: columns
# Papers
Reverting to two columns again.
  [@jianming2017;
   @piponi2000;
   @armi2019;
   @walshaw1995;
   @xu2011;
   @wei2004;
   @vanwaveren2006;
   @maggiordomo2021;
   @maggiordomo2020;
   @zhang2020;
   @czachurski2022;
   @gal2010;
   @norynchak2021]

:::
\clearpage
<!--- send bibliography into two-column --->
\twocolumn

Here is what it looks like: bib-2col-B

You must log in to answer this question.

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