5

I write a document on several machines. One of them has Ubuntu 14.04 installed with a kind of dated installation of TexLive. The others have Ubuntu 14.10 and Arch Linux.

In my document I use the arrows.meta library. Now I am stuck with a document that does not compile on one of my machines (the 14.04 one).

Is there a way, I can make latex to ignore all the problematic definitions. What I would like to have is something (perhaps a few lines of code to comment in and out) to enable and disable the newer features of TikZ without changing the source files of the actual images? Right now its 9 images using the arrows.meta tips and this number might grow. So, changing the image's source is not the way to go.

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}        % font encoding
\usepackage[utf8]{inputenc}     % input encoding
\usepackage{lmodern}            % fonts

\usepackage{tikz,pgfplots}      % provides TikZ


\usetikzlibrary{arrows}
%\usetikzlibrary{arrows.meta}

%\newcommand{\Stealth}{\stealth}    % does not work

\begin{document}

\begin{tikzpicture}
    \draw[-Stealth] (0,0) to (1,1);
\end{tikzpicture}

\end{document}
3
  • 4
    upgrade TikZ to 3.0.0?
    – percusse
    Commented Apr 21, 2015 at 8:36
  • 1
    Upgrade TeXLive? It is incredibly straightforward.
    – user30471
    Commented Apr 21, 2015 at 8:42
  • 1
    You could use \IfFileExists... to test for whether there is an arrows.meta library. (You'll need the proper file name.) Then define a style conditionally and load the appropriate library. But only even consider this if you have no other option which would let you update, as there will inevitably be other complications to deal with.
    – cfr
    Commented Apr 21, 2015 at 11:38

1 Answer 1

7

The best solution really is to update the TeX distribution. It will save headaches in the future, and the new arrows.meta library provides many nice features.

But, if upgrade is not an option: The conditional code below will check if the version of pgf loaded is 3.0.0 or later (dated on or after 2013/12/18). If yes, we load arrows.meta and -Stealth can be used as usual. If no, alias the arrow tip called Stealth to the old stealth tip provided by library arrows.

The end result of this is that Stealth will be used if TikZ/PGF 3.0.0 is available but fall back to stealth if they are not available, without any modifications to the drawing code.

Limitations: arrow style modifiers or other options (things like -{Stealth[width=6pt]}, for example) introduced with arrows.meta will not be successfully handled by this code.

\documentclass[tikz]{standalone}

\usepackage[T1]{fontenc}    % font encoding
\usepackage[utf8]{inputenc} % input encoding
\usepackage{lmodern}        % fonts

\usepackage{tikz}           % provides TikZ
\usetikzlibrary{arrows}

\makeatletter
\@ifpackagelater{pgf}{2013/12/18}{
  \usetikzlibrary{arrows.meta}
}{
  \pgfarrowsdeclarealias{Stealth}{Stealth}{stealth}{stealth}
}
\makeatother

\begin{document}
\begin{tikzpicture}
  \draw[-Stealth] (0,0) to (1,1);
\end{tikzpicture}
\end{document}
3
  • Does it work if there are arrow options?
    – percusse
    Commented Apr 21, 2015 at 13:02
  • @percusse: Unfortunately, no, I couldn't work that bit out (see the last sentence in my answer; I'll edit to make it stand out more). Commented Apr 21, 2015 at 13:29
  • My bad. I'm blind apparently.
    – percusse
    Commented Apr 22, 2015 at 9:18

You must log in to answer this question.

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