2

In the following example, how can I redefine one property of the predefined block style in the tikzpicture environment without affecting the others:

\documentclass{article}
    \usepackage{pgfplots}
        \pgfplotsset{compat=1.12}
        \tikzstyle{block} = [rectangle, draw,minimum width=3em,]
\begin{document}
 \begin{tikzpicture} % This works ok
   \node[block, minimum width=3em,] (b1) {B1};
  \end{tikzpicture}
 \begin{tikzpicture}[block/.style={minimum width=3em,}] % This reset all styles
   \node[block] (b1) {B1};
  \end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

3

You can use the handler .append style:

\documentclass{article}
    \usepackage{pgfplots}
        \pgfplotsset{compat=1.12}
        \tikzstyle{block} = [rectangle, draw,minimum width=3em,]
\begin{document}
 \begin{tikzpicture} % This works ok
   \node[block, minimum width=3em,] (b1) {B1};
  \end{tikzpicture}
 \begin{tikzpicture}[block/.append style={minimum width=10em,}] %
   \node[block] (b1) {B1};
  \end{tikzpicture}
\end{document}

enter image description here

4
  • Cool! I have to say that tikz/pgfplots should be awarded the Most Confusing Syntax Award.
    – jak123
    Commented Jun 10, 2015 at 8:00
  • @jak123 It seems like you never tried using pstricks. Commented Jun 10, 2015 at 9:49
  • @HenriMenke Is it worse?
    – jak123
    Commented Jun 11, 2015 at 6:25
  • @jak123 It is super inconsistent, cf. this answer. Commented Jun 11, 2015 at 8:55

You must log in to answer this question.

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