Leif Andersen Leif Andersen -4 years ago 383
LaTeX Question

Create a new page in scribble with pdf/latex backend

In latex, I can create a new page with the

command. There does not seem to be any way to do this directly in Scribble (at least not for a PDF/Latex back end.)

So, how can I force scribble to make me new page for my document?

Answer Source

There is no way to create a new page in Scribble,1 at least not directly. The idea behind this is because that new pages only make sense in the context of PDF files, while Scribble tries to make sense in both HTML and PDF contexts.

You can, however, insert a bit of raw latex code in your scribble file. To do this, you first need to create a file, say: textstyle.tex, and in this file, put:


The name of the file doesn't matter, and if it has other commands in it too is fine. This is just to create a latex command that just evaluates to the same text its given.

Next, somewhere in your scribble code, you can create the following two functions:

(define (exact . items)
  (make-element (make-style "identity" '(exact-chars))

(define (newpage)
  (exact "\\newpage"))

The first function defines exact, which we can use to insert latex code. This works because The exact-chars style passes the characters into latex verbatim, and does not pass it through any sort of pre-processor. We need the identity stile here so that latex has something to put the text in.

The newpage function is then translated directly into \newpage in latex. Just call it where you want in your code as (newpage) (or @newpage[]/@(newpage) when using at-expressions).

Finally, you need to tell scribble where to find the texstyle.tex file. You can do that with the ++style flag when running scribble. Altogether, your command should look something like:

scribble --pdf ++style texstyle.tex mydocument.scrbl

As an extra, if you want the document to compile for any back end and not just latex/pdf, you can use cond-element. That way you can just have it be an empty element in any other backend:

(define (exact-latex . items)
  (cond-element [latex
                  (make-element (make-style "identity" '(exact-chars))
                [else ....]))

(define (newpage)
  (exact-latex "\\newpage"))

1 At least not as far as I can tell, please update if this changes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download