I'd like to have a shorthand for

    % ..diagram code...

I tried with

\tikzset{ampersand replacement=\&}

Where the first command should fix problems with ampersands. Without it, I get errors about them but even with it, pdflatex doesn't seem to be able to produce a right output (I get the error Package tikz: Sorry, the system call 'pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "figures/cache/main-figure1" "\def\tikzexternalrealjob{main}\input{main}"' did NOT result in a usable output file 'figures/cache/main-figure1' (expected one of .pdf:.jpg:.jpeg:.png:)...)

The error seems to occur on regular images, so maybe it's a problem of interoperability with the \tikzset command? If I disable tikz-external, the only error remaining is Float(s) lost.

  • 1
    Are you adding captions to those diagrams? If not, the figure environment is rather pointless. I'd remove it and \centering, and use a center environment instead. – Torbjørn T. Mar 11 '18 at 14:39
  • @TorbjørnT. You're right! – mattecapu Mar 11 '18 at 14:42

Apparently the error was caused by another, unrelated, tikz environment used in the wrong place.

So actually the shorthand in the question works.

| improve this answer | |
  • 1
    making such shorthands is usually in the end not a good idea, it makes it much harder for your editor to offer context sensitive syntax highlighting or help and given reasonable editor setup it does not save any typing as you should be able to add \begin{..} \end{...} in just a few keystrokes. – David Carlisle Mar 11 '18 at 15:00
  • It's a matter of consistency. If I want to change how to display my diagrams (or equations, figures, ...), I just need to edit in one place. Basic programming wisdom (DRY). Losing some syntac highlighting is often an acceptable trade off. That said, this is my experience, YMMV. – mattecapu Mar 11 '18 at 16:00

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