2

Background

Creating a custom multi-column layout having columns that differ in width.

Problem

This question's problem is mentioned but not addressed in a previous answer:

Setting page=yes causes an unfortunate side-effect: the book is interwoven with blank pages in between chapters. These can be eliminated using Ghostscript to post-process...

In other words, without the page=yes option, ConTeXt is unable to format the text as desired. With the page=yes option, ConTeXt formats as expected but exports an undesired blank page between major sections.

Code

Minimum working example that illustrates the problem:

\definepapersize[BookPaperSize][width=24in, height=12in,]
\setuppapersize[BookPaperSize]

\definelayout[BookTextLayout][
  topspace=.5in,
  backspace=.5in,
  header=\zeropoint,
  footer=\zeropoint,
  grid=yes,
]
\setuplayout[BookTextLayout]

\definecolumnset[BookColumns][n=4,distance=.25in]
\setupcolumnset[BookColumns:1][width=11.75in]
\setupcolumnset[BookColumns:2][width=3.46in]
\setupcolumnset[BookColumns:3][width=3.46in]
\setupcolumnset[BookColumns:4][width=3.46in]

\setuphead[section][
  page=yes,
  beforesection={\startcolumnset[BookColumns]},
  aftersection={\stopcolumnset},
]

\setuphead[subsection][
  after={\column},
]

\setuphead[subsubsection][
  after={\blank[small]},
]

\starttext
\startsection[title={Section Title}]
\startsubsection[title={Subtitle}]
\dorecurse{2}{\input knuth}

\dorecurse{2}{%
  \startsubsubsection[title={Subsubtitle}]
    \dorecurse{1}{\input ward}
    \dorecurse{2}{\input lorem}
    \dorecurse{1}{\input bryson}
  \stopsubsubsection
}

\stopsubsection
\stopsection
\stoptext

Actual Output

The page before each section is blank:

Actual Output

Output Without Page

When the page=yes option is removed, the output has issues:

No Page Command

The \column command no longer appears to respect the column widths and the text bunches up at the bottom of the first column.

Expected Output

The desired output would not have a blank page between major sections:

Expected Output

Work Around

The resulting PDF contains multiple pages. Using Ghostscript works to delete every other page (e.g., using gs -sPageList=even), which produces the desired result:

Example Output

However, the extra blank page causes knock-on problems: extra image processing steps, PDF pages need reordering, and increased compile time due to needing two passes.

Question

What needs to change so that the blank pages are eradicated from the document?

Ideas

Adding page=yes to the \definecolumnset and removing page=yes from the setuphead resolves the issue of blank pages; however, the first page columnset is scrunched to the left. I've attempted to address the issue using:

\definecounter[BookPageNumber][
  way=bychapter,
  prefix=no,
]

\definecolumnset[BookColumns][n=4,distance=.25in,page={\doifelse{\rawcountervalue[BookPageNumber]}{1}{}{yes}}]
\setupcolumnset[BookColumns:1][width=11.75in]
\setupcolumnset[BookColumns:2][width=3.46in]
\setupcolumnset[BookColumns:3][width=3.46in]
\setupcolumnset[BookColumns:4][width=3.46in]

\setuphead[section][
  before={%
    \doif{\rawcountervalue[BookPageNumber]}{1}{\page}
    \incrementcounter[BookPageNumber]
  },
  beforesection={\startcolumnset[BookColumns]},
  aftersection={\stopcolumnset},
]

However, this does not produce the desired output.

2

Columnsets are spread-based, i.e. when n=4 you actually have eight columns, namely four on the left page and four on the right page. A document always opens with a right page which you haven't set up and which is why adding \page[yes] helps, because it pushes the content to the left page which is set up.

So just adding columns 5-8 for the right page fixes the problem.

\definepapersize[BookPaperSize][width=24in, height=12in,]
\setuppapersize[BookPaperSize]

\definelayout[BookTextLayout][
  topspace=.5in,
  backspace=.5in,
  header=\zeropoint,
  footer=\zeropoint,
  grid=yes,
]
\setuplayout[BookTextLayout]

\definecolumnset[BookColumns][n=4,distance=.25in]
\setupcolumnset[BookColumns:1][width=11.75in]
\setupcolumnset[BookColumns:2][width=3.46in]
\setupcolumnset[BookColumns:3][width=3.46in]
\setupcolumnset[BookColumns:4][width=3.46in]
\setupcolumnset[BookColumns:5][width=11.75in]
\setupcolumnset[BookColumns:6][width=3.46in]
\setupcolumnset[BookColumns:7][width=3.46in]
\setupcolumnset[BookColumns:8][width=3.46in]

\setuphead[section][
  %page=yes,
  beforesection={\startcolumnset[BookColumns]},
  aftersection={\stopcolumnset},
]

\setuphead[subsection][
  after={\column},
]

\setuphead[subsubsection][
  after={\blank[small]},
]

\starttext
\startsection[title={Section Title}]
\startsubsection[title={Subtitle}]
\dorecurse{2}{\input knuth}

\dorecurse{2}{%
  \startsubsubsection[title={Subsubtitle}]
    \dorecurse{1}{\input ward}
    \dorecurse{2}{\input lorem}
    \dorecurse{1}{\input bryson}
  \stopsubsubsection
}

\stopsubsection
\stopsection
\stoptext

enter image description here

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.