5

I have a defined style which I am applying to many arrows. Most of the time, I want them to have label nodes positioned using auto, but occasionally I do not. Currently, I simply add auto wherever necessary. Since auto is the default, though, it would seem more natural to include it in the style; but if I do so, is there a way to occasionally turn it off?

Currently writing e.g.:

\begin{tikzpicture}
          [myarrow/.style={->,font=\scriptsize}]
  \draw[myarrow,auto] (0,0) to node {L} (0,1);
  \draw[myarrow,auto] (1,0) to node {L} (1,1);
  \draw[myarrow,auto] (2,0) to node {L} (2,1);
  \draw[myarrow] (3,0) to node {M} (3,1);
\end{tikzpicture}

Would prefer to write something like:

\begin{tikzpicture}
          [myarrow/.style={->,font=\scriptsize,auto}]
  \draw[myarrow] (0,0) to node {L} (0,1);
  \draw[myarrow] (1,0) to node {L} (1,1);
  \draw[myarrow] (2,0) to node {L} (2,1);
  \draw[myarrow,not auto] (3,0) to node {M} (3,1);
\end{tikzpicture}

but I don’t know what to put for not auto.

  • @percusse: OK, I fail on reading comprehension — I had looked over that section of the manual several times over and somehow missed this! If you make that an answer, I’ll accept it. – Peter LeFanu Lumsdaine Feb 27 '13 at 22:14
  • No problem at all. The CVS version manual is 1052 pages ;) – percusse Feb 27 '13 at 22:39
5

The auto option is both an anchor selector and at the same time an on/off switch. That means you can both use auto=<left,right> and auto=<true,false>.

For the interested

\tikzoption{auto}[]{\csname tikz@install@auto@anchor@#1\endcsname}

is how it is defined. So whatever option is given replaces #1 and providing false option or just using auto causes the following to be triggered.

\def\tikz@install@auto@anchor@{\let\tikz@do@auto@anchor=\tikz@auto@anchor@on}
\def\tikz@install@auto@anchor@false{\let\tikz@do@auto@anchor=\relax}

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.