2

SE,

I am not experienced at TikZ at all, so I decided to use Inkscape. Using Inkscape, I recreated this diagram (p. 13)Screenshot. In Inkscape, it looks pretty good, with the labels (i.e. Eluent and Probe) nicely moved from the part.

However, if I save it as a PDF, following this workflow, I get the following (yellow boxes added to show issues): Screenshot Two

In some cases (e.g. Trennsäule), the text isn't in conflict with the image. However, in the outlined cases, it is.

Is there a way to adjust the labels manually, if you have the .pdf_tex?

.pdf_tex:

%%Removed all the text above to reduce the code.
\begingroup%
  \makeatletter%
  \providecommand\color[2][]{%
    \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
    \renewcommand\color[2][]{}%
  }%
  \providecommand\transparent[1]{%
    \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
    \renewcommand\transparent[1]{}%
  }%
  \providecommand\rotatebox[2]{#2}%
  \newcommand*\fsize{\dimexpr\f@size pt\relax}%
  \newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
  \ifx\svgwidth\undefined%
    \setlength{\unitlength}{300.47244094bp}%
    \ifx\svgscale\undefined%
      \relax%
    \else%
      \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
    \fi%
  \else%
    \setlength{\unitlength}{\svgwidth}%
  \fi%
  \global\let\svgwidth\undefined%
  \global\let\svgscale\undefined%
  \makeatother%
  \begin{picture}(1,0.50943396)%
    \lineheight{1}%
    \setlength\tabcolsep{0pt}%
    \put(0,0){\includegraphics[width=\unitlength,page=1]{drawing.pdf}}%
    \put(0.01946427,0.0958815){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Eluent\end{tabular}}}}%
    \put(0.14899702,0.09653322){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}HPLC-Pumpe\end{tabular}}}}%
    \put(0.36244725,0.30626527){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Injektionsventil\end{tabular}}}}%
    \put(0.45561144,0.10247889){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Probe\end{tabular}}}}%
    \put(0.64807278,0.01856142){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Detektor\end{tabular}}}}%
    \put(0.40054089,0.41600586){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Trennsäule\end{tabular}}}}%
    \put(0.72131691,0.47639177){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Nachreaktor /\\Derivatisierung\end{tabular}}}}%
    \put(0.78010564,0.11191285){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Leitfähigkeit\\UV-VIS\\Amperometrie\\Atomspektrometrie\end{tabular}}}}%
    \put(0.09818964,0.34282572){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Probeschleife\end{tabular}}}}%
    \put(0,0){\includegraphics[width=\unitlength,page=2]{drawing.pdf}}%
  \end{picture}%
\endgroup%

drawing.pdf

The .tex file:

\documentclass[11pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{transparent}
\begin{document}
\begin{figure}
\def\svgwidth{\textwidth}
\input{drawing.pdf_tex}
\caption{A caption.}
\end{figure}
\end{document}
1

In my experience, it is easier to apply some tweaks to the SVG file and then re-export to PDF+TeX. Trying to adjust the pdf_tex is nearly as complicated as doing the full drawing in TikZ from the start.

From your pdf_tex I see a lot of \makebox(0,0)[lt] which means you chose left-alignment for all your text elements. This brings you into trouble when the font size in Inkscape doesn't match the font size in LaTeX. So there are two ways:

  • Adjust the font size by adding one of \small, footnotesize, etc. before your input (perhaps in a group, {\small\input{drawing.pdf_tex}}) such that the text takes roughly the same space as in Inkscape and the overlays vanish.

  • The export to PDF+TeX respects the horizontal alignment chosen in Inkscape. As an example, changing "Probeschleife" to right-aligned in Inkscape (the text there will still be in the same position) results in a \makebox(0,0)[rt], and thus the text will not overlay with the drawings to the right even if the text is larger than in Inkscape.

So, my advice is: In Inkscape, use left-alignment for labels right of the drawings, right-alignment for labels left of the drawings, and center-alignment for labels below/above the drawings; and then experiment with different font sizes right in front of the \input statement.

  • Thank you for your answer. I will try it out. – Max R Feb 9 at 13:24
  • It got rid of the overlaps, however the labels are shifted right, even tough I set them center-aligned in Inkscape and center aligned them with the object. – Max R Feb 9 at 14:01

Your Answer

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

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