Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page breaks on top level heading (h1 / #) #14

Closed
eben-roux opened this issue Oct 29, 2017 · 7 comments
Closed

page breaks on top level heading (h1 / #) #14

eben-roux opened this issue Oct 29, 2017 · 7 comments
Labels

Comments

@eben-roux
Copy link

I really like this template.

I'm using it for a book I'm self-publishing. As I understand you are not specifically targeting books but since my book show sample C# code I need something to properly format the code and your template does the trick.

Using documentclass: book seems to break things so I've removed that.

I would like to place page breaks on the top level headings (# in my markdown). For that I've tried the titlesec package and include a header-includes to a titlesec.tex file with the following:

% titlesec setup
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

However, this results in the following error:

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.100 t

This is really my first outing with pandoc so any help would be appreciated. I have been struggling quite a while trying to get a decent output and I feel that I'm almost there :)

@martinlarsson
Copy link
Contributor

I too struggled with this a while back and couldnt get it to work. Ended up with entering \newpage at the top of each markdown file (ie top level heading).

@Wandmalfarbe
Copy link
Owner

I'm glad you like it! This really means a lot to me.

First of all I used the KOMA-Script class scrartcl as the document class because it has some advantages over the default article class. For typesetting a book I recommend the corresponding KOMA-Script class scrbook instead of the default book. All the examples should work with the KOMA-Script class.

To get the correct chapter headings (and page breaks before them) you need to tell pandoc that it should convert first level headings # to chapters with the command --top-level-division=chapter (-> Manual).

There will be one blank page before each chapter because the template is two-sided per default (I think I should change that). So if you plan to publish your book as a PDF and don't need a blank page you should add the class option onesided which can be done by supplying a template variable -V classoption=oneside (-> Manual).

Unfortunately I never really tested chapters with my template so there are some strange chapter headings. I filed a new Issue (#16) and try to figure out what's wrong.

@eben-roux
Copy link
Author

Thanks a stack for the feedback. I'll give it a go.

@eben-roux
Copy link
Author

@martinlarsson: my brain only really registered your message now :)

My entire document is in one markdown file. Would one add that \newline before each # Heading then?

@martinlarsson
Copy link
Contributor

Yeah, I think that would do the trick. But \newpage instead of \newline :)

@eben-roux
Copy link
Author

lol: goodness... thanks!

@Wandmalfarbe
Copy link
Owner

Just a quick note for everyone having the same problem. You can insert two commands into the template with header-includes to create a pagebreak for every top level heading (see also #81):

---
title: "Example PDF"
author: [Author]
date: "2017-02-20"
subject: "Markdown"
keywords: [Markdown, Example]
lang: "en"
header-includes: |
    \usepackage{sectsty}
    \sectionfont{\clearpage}
...

# Vinaque sanguine metuenti cuiquam Alcyone fixus

Lorem markdownum Letoia, et alios: figurae flectentem annis aliquid Peneosque ab
esse, obstat gravitate. Obscura atque coniuge, per de coniunx, sibi **medias
commentaque virgine** anima tamen comitemque petis, sed. In Amphion vestros
hamos ire arceor mandere spicula, in licet aliquando.

# Aesculeae domus vincemur et Veneris adsuetus lapsum

Lorem markdownum Letoia, et alios: figurae flectentem annis aliquid Peneosque ab
esse, obstat gravitate. Obscura atque coniuge, per de coniunx, sibi **medias
commentaque virgine** anima tamen comitemque petis, sed. In Amphion vestros
hamos ire arceor mandere spicula, in licet aliquando.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants