3

MWE

\RequirePackage{luatex85}
\documentclass[
  tikz,
  border=0cm,
  class=scrbook,
]{standalone}
\usetikzlibrary{backgrounds}
\pagecolor{lightgray}
% \KOMAoptions are actually included via a shared file
\KOMAoptions{
  paper=a4,
  fontsize=10pt,
  % INCORRECT CROP APPEARS WITH ANY OF FOLLOWING OPTIONS
  BCOR=10mm,
  % twoside,
  % DIV=14,
  % headinclude=false,
}
% \recalctypearea % THIS CAN ALSO BE RESPONSIBLE FOR AN INCORRECT CROP
\usepackage{layouts}
\begin{document}%
  \begin{tikzpicture}[framed]
      \draw[rectangle, use as bounding box] (-4,-8.5) |- (8,6.3) |- cycle;
      \node[text width=8cm] at (0,0) {\pagevalues};
  \end{tikzpicture}%
\end{document}

enter image description here

As you can see the document is not properly cropped. Commenting BCOR will result in a correct crop.

What can I do to get a properly cropped picture?

Moving away from the package standalone would mean a rather large change of my actual document and organization of my latex project (see for more details Luatex v0.95+standalone: \RequirePackage{luatex85} cannot be used in outsourced tikz). I probably should also note that I want to use values such as \textwidth in the tikzpicture to automatically place things according to the available textarea.

4
  • And why do you use BCOR in a standalone document? It only makes life harder. Separate your preamble code in "code needed also by standalone" and "code only for real document". Feb 10, 2017 at 12:56
  • I think BCOR reduces the \textwidth and that's a parameter I want to use in my tikz picture to facilitate the maximum possible horizontal space. I already have a preamble in my main.tex and a shared_preamble_part.tex which only contains items which are needed by both.
    – Hotschke
    Feb 10, 2017 at 13:00
  • 1
    Setting BCOR results in a recalculation of the page layout similar to \recalctypearea. Set the options regarding the typearea calculations as class options: \documentclass[...,class=scrbook,paper=a4,fontsize=10pt,BCOR=100]{standalone}
    – esdd
    Feb 10, 2017 at 13:13
  • Thanks. Yes, that does resolve the issue. Any chance to share these values between several standalone and the main tex file?
    – Hotschke
    Feb 10, 2017 at 13:15

1 Answer 1

4

Beside using class options you can also reset the layout values to one expected by standalone after using the KOMA-keys:

\RequirePackage{luatex85}
\documentclass[
  tikz,
  border=0cm,
  class=scrbook,
]{standalone}
\usetikzlibrary{backgrounds}
\pagecolor{lightgray}
\KOMAoptions{
  paper=a4,
  fontsize=10pt,
   BCOR=10mm,
  % twoside,
  % DIV=14,
  % headinclude=false,
}
\makeatletter
\ifsa@crop
\pagestyle{empty}
\hoffset=-72.27pt
\voffset=-72.27pt
\topmargin=0pt
\headheight=0pt
\headsep=0pt
\marginparsep=0pt
\marginparwidth=0pt
\footskip=0pt
\marginparpush=0pt
\oddsidemargin=0pt
\evensidemargin=0pt
\topskip=0pt
\fi
\makeatother
\usepackage{layouts}
\begin{document}%
  \begin{tikzpicture}[framed]
      \draw[rectangle, use as bounding box] (-4,-8.5) |- (8,6.3) |- cycle;
      \node[text width=8cm] at (0,0) {\pagevalues};
  \end{tikzpicture}%
\end{document}
3
  • Thanks for your answer. I think I do not understand what values are expected by standalone. Do I have to modify values such as \hoffset=-72.27pt when I change KOMAoptions?
    – Hotschke
    Feb 10, 2017 at 13:24
  • I don't understand your question. I copied the values from standalone in my answer and it compiles fine. Feb 10, 2017 at 13:27
  • I had a look into standalone.cls and I have found the values you've copied. I think this should do the trick as you've said. A minor issue is in your answer: there is a missing \makeatother. With this it also compiles fine for me.
    – Hotschke
    Feb 10, 2017 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .