4

I am trying to concentrate often used options for a tikzpicture under a tikzset command in the preamble, to share among different pictures. My MWE is:

\documentclass[crop,tikz]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} % \tikzset{every picture/.append style{line cap=round, line width=1.5pt, {-Latex[round]}}} \begin{document} \begin{tikzpicture} [line cap=round, line width=1.5pt, {-Latex[round]}] \draw [blue](0, 0) -- (0.5, 1); \draw [red] (0, 0) -- (1, 0.25); \end{tikzpicture} \end{document} 

The file compiles well as is, but does not if I comment out the options after \begin{tikzpicture} and uncomment the line with tikzset in the preamble.

How can I get the tikzset command to work so that I may, dispense with the options after \begin{tikzpicture}

1
  • Trying what you have suggested gives me the correct arrow tip but the line cap and line width are not recognized and are default. I want an invocation that can set all three in one go. Is that at all possible? Commented Nov 19, 2023 at 7:23

1 Answer 1

5

You are missing an = in your \tikzset command. But additionally, I wouldn't use .append for this but instead use .style:

\documentclass[crop,tikz]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \tikzset{every picture/.style={line cap=round, line width=1.5pt, {-Latex[round]}}} \begin{document} \begin{tikzpicture} \draw [blue](0, 0) -- (0.5, 1); \draw [red] (0, 0) -- (1, 0.25); \end{tikzpicture} \end{document} 
3
  • Such a foolish error on my part! Thank you @Alan Munn. It now works as I intended. Commented Nov 19, 2023 at 7:28
  • You might want to explain why you prefer .style, since this really isn't obvious from the manual. @chandra If you're curious, \tikzset{/handlers/.add code/.show code,/handlers/.code/.show code} will show you (what I assume to be) the reason on the terminal ;). Commented Nov 19, 2023 at 7:33
  • I have just started reading 87.1.2 Quick Guide to Using the Key Mechanism in the manual. I had always wondered about the dot. Now it is clearer. Thanks @cfr. Commented Nov 19, 2023 at 7:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.