[XeTeX] XeTeX output of less than a complete page

Bruno Voisin bvoisin at mac.com
Tue Aug 16 13:38:25 CEST 2005


Le 15 août 05 à 22:44, Peter Dyballa a écrit :

> LaTeXiT (http://ktd.club.fr/programmation/latexit.php) is an  
> application to create big scaled images of for example a formula to  
> embed it in another application's file. Recently it was asked  
> whether XeLaTeX could be used to create such images too. LaTeXiT  
> allows the use of XeLaTeX instead of pdfLaTeX, but when it comes to  
> scaling of the produced picture it comes to an end: while pdfLaTeX  
> produces a tight BoundingBox, XeLaTeX creates one as big as the  
> sheet of paper used.
>
> Is there a way to create such a tight output with xdv2pdf?
>
> Or is there a clever tool that can crop the proper image from the  
> page?
>
> The test code Pierre Chatelier uses is:
>
>     [...]
>     \usepackage{geometry}
>     [...]
>     \closeout\foo \geometry{paperwidth=\latexitwidth,paperheight= 
> \latexitheight,margin=0pt,left=0.000000 pt,top=0.000000 pt}
>     [...]

OK, I had a look at this code finally. I don't think things can work  
for now:

- There isn't any xetex driver for the geometry package. It seems  
[dvips] is the default option. I tried using [dvipdfm] instead (XeTeX  
understands some dvipdfm \special's), but that didn't have any  
noticeable effect. Then I replaced the use of the geometry package by  
standard LaTeX commands:

     \setlength{\oddsidemargin}{0pt}
     \addtolength{\oddsidemargin}{-1in}
     \setlength{\evensidemargin}{\oddsidemargin}
     \setlength{\paperwidth}{\latexitwidth}
     \setlength{\textwidth}{\paperwidth}
     \setlength{\topmargin}{0pt}
     \addtolength{\topmargin}{-1in}
     \setlength{\headheight}{0pt}
     \setlength{\headsep}{0pt}
     \setlength{\paperheight}{\latexitheight}
     \setlength{\textheight}{\paperheight}
     \usepackage{ifpdf}
     \ifpdf
       \setlength{\pdfpagewidth}{\latexitwidth}
       \setlength{\pdfpageheight}{\latexitheight}
       \setlength{\pdfhorigin}{0pt}
       \setlength{\pdfvorigin}{0pt}
     \fi

but that didn't help either.

- The problem, I remember now, goes deeper than the mere geometry  
package: XeTeX doesn't have native commands for specifying the media  
size, such as

     \pdfpageheight=\latexitheight
     \pdfpagewidth=\latexitwidth

for pdfTeX, or \special's, such as

     \special{papersize=\latexitwidth,\latexitheight}

for dvips; these are the tricks that are used by the geometry  
package. Instead, the media size must be given as an argument to  
xetex, using a syntax that's described for the xdv2pdf converter from  
XeTeX's XDV extended DVI format to PDF:

$ xdv2pdf -h
usage: xdv2pdf [-m mag] [-p papersize[:landscape]] [-v] [-o pdfFile]  
xdvFile
     papersize values: a0/a1/a2/a3/a4/a5/a6/a7/a8/a9/a10/b0/b1/b2/b3/ 
b4/b5/b6/b7/b8/b9/b10/c0/c1/c2/c3/c4/c5/c6/c7/c8/c9/c10/jb0/jb1/jb2/ 
jb3/jb4/jb5/jb6/jb7/jb8/jb9/jb10/letter/legal/tabloid/ledger/wd,ht  
[in 'big' points or with explicit units]

With xetex, that becomes a -papersize option.

In a thread "[XeTeX] Papersizes" on 13 October 2004, Jonathan Kew said:

> The -papersize option to xe(la)tex should set the media dimensions  
> for the generated PDF. If that doesn't work, it's a xetex bug, and  
> should be reproducible with a minimal "plain" test case.
>
> [...]
>
> How LaTeX packages (classes, whatever) interact with paper sizes is  
> beyond my knowledge, but I think it's likely that in order to use  
> something like b5, you'd need to specify the size *both* to the  
> engine, with -papersize, and to LaTeX with some kind of class  
> option. (b5? b5paper? I don't know. What's the difference?)
>
> With pdflatex, there's probably a pdftex primitive that the LaTeX  
> class can use to set the media size, and that won't work in xetex.  
> Eventually, perhaps we'll get a pdfmark-based extension into  
> xdv2pdf to support this.

and later he described the XeTeX syntax for media size specification:

> Seems to work for me. I just tried this:
>
> Kew:~ jonathan$ xetex -papersize=1008pt,612pt
> This is XeTeXk, Version 3.14159-2.1-0.88 (Web2C 7.5.2)
>  %&-line parsing enabled.
> **\relax
> entering extended mode
>
> *hello\bye
> [1]
> Output written on texput.pdf (1 page).
> Transcript written on texput.log.
> Kew:~ jonathan$ open texput.pdf
>
> and Acrobat Reader confirms that the document created is 13.95 x  
> 8.47 inches; sounds right to me.

Thus you would need to run xetex with the option "-p \latexitwidth, 
\latexitheight", after figuring out a way to pass on \latexitwidth  
and \latexitheight as arguments to the -p option, in the appropriate  
unit. Some sort of LaTeX programming challenge!

Hope this helps,

Bruno Voisin 
    



More information about the XeTeX mailing list