0

As the external package from tikz did not work (I don't know why) I switched just using the standalone documentclass for making my plots and pictures.

However, I receiving serious issues compiling when caomparing the reuslts compared either with the standalone class or dircetly using my main.file.

My approach is as follows:

I create and tune the picture via standalone . For this I load all settings I used in my main document so the fonts and distances will be displayed in that way there are finally correct. At the end of my project I will then let the main.tex compile the code I created in my standalone-file so that references and maybe cites will be correct displayed.

MWE

main.tex

\documentclass[10pt,a4paper,oneside,headsepline, headings=small,openright, fleqn,appendixprefix,BCOR=5mm,
%draft,
]{scrbook}

\usepackage[includeheadfoot,left=3cm,right=2cm,top=2cm,bottom=2cm,showframe]{geometry}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16,width= .6\textwidth,scale only axis,}

\begin{document}

\centering
\begin{tikzpicture}
\begin{axis}
\addplot [] coordinates {(0,0) (1,2) (2,3)};
\end{axis}
\end{tikzpicture}

\begin{figure}[h]
\centering
\includegraphics{standalone.pdf}
\caption{}
\end{figure} 

\end{document}

standalone.tex

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16, width= .6\textwidth}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot [] coordinates {(0,0) (1,2) (2,3)};
\end{axis}
\end{tikzpicture}
\end{document}

Now the problem presented in this picture:

enter image description here

The plot below is the .pdf from the standalone. There are two problems:

  • there seems to be a problem with the width
  • more problematic: when looking in the upper right corner and the axis-tick-labels the distances inside the plot are quite different

After try and error I find out that there seems to be something with the geometry package. When I add this to my standalone-file

\usepackage[includeheadfoot,left=3cm,right=2cm,top=2cm,bottom=2cm,showframe]{geometry}

the internal distances are now identical with the plot created via the main-file. However, the picture now gets shifted and cropped:

enter image description here

Anyone an idea what can cause this problem (using geometry?) and how to fix this?

  • 1
    Well, \textwidth has a different value in standalone vs. scrbook. If you use the value of scrbook, it should be fine. – marmot Aug 27 '18 at 16:34
  • Whend using the scrbook values how could I then implement the extrawidth caused by the geometry-package? – SRel Aug 27 '18 at 16:37
  • One possibility, certainly not the most elegant one, is to add \typeout{\the\textwidth} to your scrbook document. This tells you that the text width is 455.24411pt there. You can use this width then in the standalone document. – marmot Aug 27 '18 at 16:41
  • You are right thank you. Using absoulte values like 12cm results in the same image. Using the geometry package in the standalone doesn't make sense I see. However as I simply load the shared preamble of the main.tex the geoemtry package is loaded then resulting in the shift. Can I somehow prevent the standalone class loading this explicit packgae? – SRel Aug 27 '18 at 17:27
  • 1
    I tried everything mentioned on differetn pages using the geometry package with and without 'pass' but stillt the size is not correct or the plot is shifted. I will make another question for this – SRel Aug 27 '18 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.