Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have this piece of LaTeX:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
% Source: http://tex.stackexchange.com/a/15278/5645

\usepackage{chessboard}
\storechessboardstyle{4x4}{maxfield=d4}

\begin{document}
\begin{preview}

% showmover shows which player is to move
\chessboard[style=4x4,setwhite={Qa1,Qd2},showmover=false]

\end{preview}
\end{document}

And I compile using pdflatex.

But the PDF document is too wide (just mark the image to see its width)

chess board - too wide

How can I make the width of the PDF equal to the of the chessboard?

share|improve this question
    
You could also remove the extra whitespace in a separate step using pdfcrop. –  Lev Bishop Sep 11 '12 at 6:34

2 Answers 2

up vote 10 down vote accepted

The problem is the blank lines in the preview environment. You'll get a tight box by removing them:

\begin{preview}
% showmover shows which player is to move
\chessboard[style=4x4,setwhite={Qa1,Qd2},showmover=false]
\end{preview}

See also Standalone package creates a page with a fixed width

share|improve this answer
1  
The blank lines create a paragraph, so the output is \linewidth wide. Removing the lines will give you only an horizontal box with no added space. –  Martin Scharrer Sep 11 '12 at 6:32

Case 1

standalone has an option border that you can use to specify the left, bottom, right, top borders. Negative values can also be used to trim. 

enter image description here

\documentclass[preview,border={-8pt -8pt -18pt -18pt}]{standalone}
% Source: http://tex.stackexchange.com/a/15278/5645

\usepackage{chessboard}
\storechessboardstyle{4x4}{maxfield=d4}

\begin{document}
% showmover shows which player is to move
\chessboard[style=4x4,setwhite={Qa1,Qd2},showmover=false]
\end{document}

Case 2

If you want to have equal borders or trimmed offset, just use one value border=-5pt for example.

enter image description here

\documentclass[preview,border=-5pt]{standalone}
% Source: http://tex.stackexchange.com/a/15278/5645

\usepackage{chessboard}
\storechessboardstyle{4x4}{maxfield=d4}

\begin{document}
% showmover shows which player is to move
\chessboard[style=4x4,setwhite={Qa1,Qd2},showmover=false]
\end{document}

Remarks: The red rectangles were added when I converted the PDF output to PNG. They are useful to show the edges of the outputs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.