Multiple Column Pages
This section contains information about how to handle pages that have multiple columns.
How to Use a Two Column Layout
Change Layout for Predefined Pages
First, you need to identify which of the pages need to be changed. Pages are already defined for the cover page, table of contents, chapter content, and others. The complete list is here: Default Page Definitions.
Next, add the column-count
and column-gap
properties to
that page. For example:
@page chapter{
column-count:2;
column-gap:1in;
}
If you need some of the elements to expand on all the columns, use the
column-span:all
CSS property. The next snippet makes the chapter titles
span both columns:
*[class ~= "topic/topic"][is-chapter] > *[class ~= "topic/title"] {
column-span:all;
}
column-count
and column-gap
properties into account if
they are set on @page
rules, not on elements from the content.Change Layout for a Specific Topic
If you need to have a different column layout for just one topic, you can use the following technique:
- Define an
outputclass
on the topic root element.<topic outputclass="two_columns" ...
- Define a CSS rule that changes the
page
property for the matching element.*[class ~= "two_columns"], *[outputclass ~= "two_columns"]{ page: two_column_page !important; }
Tip: In the selector, use theclass
attribute for the HTML transformation, oroutputclass
for the direct transformation, or leave them both if you are not sure.Note: The topics from the first level use thechapter
page. You must use!important
because the built-in rules are more specific and you need to override thepage
property. - Define a page
layout.
@page two_column_page { column-count: 2; }
Note that the topic will be separated from other sibling topics with different page layouts by page breaks.
Change Column Breaks for Headings
If you need to start each topic on a new column, you can use the following technique:
<map>
<title>Map</title>
<topicref href="first.dita">
<topicref href="second.dita"/>
</topicref>
<topichead navtitle="Topichead">
<topicref href="second.dita"/>
</topichead>
</map>
@page {
column-count: 2;
}
*[class ~= "topic/topic"] *[class ~= "topic/topic"] > *[class ~= "topic/title"] {
-oxy-column-break-before: always;
}
*[class ~= "topic/title"] + *[class ~= "topic/topic"] > *[class ~= "topic/title"] {
-oxy-column-break-before: auto;
}
Each topic will be displayed on a new column except for topics that only have a title and no content.