我有这段 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}
我使用 pdflatex 进行编译。
但 PDF 文档太宽(只需标记图像即可查看其宽度)
如何使 PDF 的宽度与棋盘的宽度相等?
答案1
问题在于预览环境中的空白行。删除这些空白行后,您将得到一个紧密的框:
\begin{preview}
% showmover shows which player is to move
\chessboard[style=4x4,setwhite={Qa1,Qd2},showmover=false]
\end{preview}
也可以看看独立包创建固定宽度的页面
答案2
情况1
standalone
有一个选项border
可用于指定左、下、右、上边框。负值也可用于修剪。
\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}
案例 2
如果您想要有相等的边框或修剪的偏移,只需使用一个值border=-5pt
即可。
\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}
备注:红色矩形是我将 PDF 输出转换为 PNG 时添加的。它们有助于显示输出的边缘。