#StackBounty: #tikz-pgf Using TikZ limits with high precision results in `pgfplots: the current plot has no coordinates (or all have be…

Bounty: 50

When I attempt to use high precision values for xmin and xmax in TikZ, all elements appear to be filtered away. Specifically,

begin{tikzpicture}
begin{axis}[
xmin=0.9030, xmax=0.9129,
]
addplot [black]
table {%
0.9035 19.8014
};
end{axis}
end{tikzpicture}

compiles correctly. But adding 9000 to each x value, changing the code to:

begin{tikzpicture}
begin{axis}[
xmin=9100.9030, xmax=9100.9129,
]
addplot [black]
table {%
9100.9035 19.8014
};
end{axis}
end{tikzpicture}

results in an error:

Warning:(1) pgfplots: the current plot has no coordinates (or all have been filtered away)

This suggests that TikZ cannot handle limit values with the precision required by values such as xmin=9100.9030 and xmax=9100.9129.

Is there a way I can allow the plot to have limits with such precision? If not, are there suggested workarounds?


Get this bounty!!!

#StackBounty: #tikz-pgf #theorems How to make the theorem environment flow around campa's code for TeXbook's bend symbol?

Bounty: 50

This is a follow up question to this comment. How can I make campa’s code for TeXbook’s bend symbol work with the theorem environment?

Consider the following LaTeX code which I saved in a file called test.tex:

documentclass{scrartcl}
usepackage{tikz}
newenvironment{mydanger}[1]{%
  sbox0{%
     begin{tikzpicture}[scale=.3]
        draw[rounded corners=.1] (-.05,-1.5)--++(0,2.55)--++(.1,0)--++(0,-2.55);
        draw[fill=white,rounded corners=1] (0,1)--(1,0)--(0,-1)--(-1,0)--cycle;
        draw[very thick](-.3,-1.5)--(.3,-1.5);
        node at (0,0) {small#1};
     end{tikzpicture}
  }%       this space ^^^ is here for a reason!
  parmedskip  noindent
  hangindentwd0
  parindenthangindent
  hangafter=-2
  setbox0=hbox to0pt{hsslower3exbox0}%
  dp0=0pt
  box0
  small
  ignorespaces
 }{parsmallskip}
newtheorem{theorem}{Theorem}
usepackage{lipsum}
begin{document}
begin{mydanger}{A}
lipsum[1]
end{mydanger}

vspace{1cm}

begin{mydanger}{A}
begin{theorem}
lipsum[1]
end{theorem}
end{mydanger}
end{document}

When I run this code with lualatex test, the following output is typeset:

Bourbaki's bend symbol with the theorem environment

I’d like the theorem paragraph to flow around the bend symbol like the regular paragraph above it.


Important requirement

The solution must be consistent with the possibility of adding margin notes via marginpar inside the theorem. Therefore, for instance, a solution that encapsulates the theorem inside an invisible tcolorbox will not be an acceptable solution; see here.


Get this bounty!!!

#StackBounty: #tikz-pgf #theorems How to make the theorem environment flow around campa's code for TeXbook's bend symbol?

Bounty: 50

This is a follow up question to this comment. How can I make campa’s code for TeXbook’s bend symbol work with the theorem environment?

Consider the following LaTeX code which I saved in a file called test.tex:

documentclass{scrartcl}
usepackage{tikz}
newenvironment{mydanger}[1]{%
  sbox0{%
     begin{tikzpicture}[scale=.3]
        draw[rounded corners=.1] (-.05,-1.5)--++(0,2.55)--++(.1,0)--++(0,-2.55);
        draw[fill=white,rounded corners=1] (0,1)--(1,0)--(0,-1)--(-1,0)--cycle;
        draw[very thick](-.3,-1.5)--(.3,-1.5);
        node at (0,0) {small#1};
     end{tikzpicture}
  }%       this space ^^^ is here for a reason!
  parmedskip  noindent
  hangindentwd0
  parindenthangindent
  hangafter=-2
  setbox0=hbox to0pt{hsslower3exbox0}%
  dp0=0pt
  box0
  small
  ignorespaces
 }{parsmallskip}
newtheorem{theorem}{Theorem}
usepackage{lipsum}
begin{document}
begin{mydanger}{A}
lipsum[1]
end{mydanger}

vspace{1cm}

begin{mydanger}{A}
begin{theorem}
lipsum[1]
end{theorem}
end{mydanger}
end{document}

When I run this code with lualatex test, the following output is typeset:

Bourbaki's bend symbol with the theorem environment

I’d like the theorem paragraph to flow around the bend symbol like the regular paragraph above it.


Important requirement

The solution must be consistent with the possibility of adding margin notes via marginpar inside the theorem. Therefore, for instance, a solution that encapsulates the theorem inside an invisible tcolorbox will not be an acceptable solution; see here.


Get this bounty!!!

#StackBounty: #tikz-pgf #positioning #graphs Placement of several graphs in the same tikzpicture

Bounty: 50

I am trying to produce this image, which includes three labels, and three graphs, all automatically generated by a (Java) program. The program generates graphs (specifically, of finite state automata) and employs LaTeX and TikZ to present these graphs to clients. The graphs tend to be large, often very large, and it is very difficult to pro-grammatically make adjustment to the process for the purpose of rendering.

enter image description here

The above image was generated by the LaTeX input at the end of this questions. You will notice that it is consists of three nodes, and three graphs. They are placed with magic numbers which I worked out manually. It is fairly easy to add anything before or after
the graphs, but it is not possible to tweak the actual list of nodes and edges. It is also not possible to know in advance which nodes would be present on the graphs.

The question is whether it is possible to enclose the graphs and nodes with something that would compute their size, and place them, e.g., in a chain.

Yet another restriction is that the entire spiel should be in a single tikzpicture environment.

  documentclass{sciposter}
  usepackage[paperwidth=84cm,paperheight=120cm,centering,textwidth=74cm,textheight=100cm,left=2cm,top=2cm]{geometry}
  
  usepackage{tikz}
  begin{document}
  usetikzlibrary{graphs,chains,shapes,quotes}
  usetikzlibrary{automata, positioning, arrows}
  usetikzlibrary{graphdrawing}
  usegdlibrary{trees,force,layered,circular}
  tikzstyle{accept}=[fill=green!50]
  tikzstyle{initial}=[circle,draw]
  tikzstyle{every node}=[rectangle]
  tikzstyle{epsilon}=[]
  tikzstyle{graphs/every graph}=[simple necklace layout,
  nodes={ellipse,fill=olive!20,inner sep=2pt,outer sep=2pt}, level sep =12ex, sibling sep=4ex, node distance = 35ex]
  
  
  defmagicOne{(0,-3)}
  defmagicTwo{(0,-63)}
  defmagicThree{(0,-95)}
  begin{tikzpicture}
  node at (0,0) {Huge NFSA};
  node at (0,-61) {Huge DFSA};
  node at (0,-92)  {Huge Minimized DFSA};
  begin{scope} path magicOne
  graph{
     "$q_{0}$" [initial,accept] -> ["varepsilon"] "$q_{1}$" ;
     "$q_{0}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{0}$"  -> [""] "$q_{3}$" ;
     "$q_{0}$"  -> [""] "$q_{8}$" ;
     "$q_{0}$"  -> ["varepsilon",loop] "$q_{0}$" ;
     "$q_{1}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{1}$"  -> [""] "$q_{3}$" ;
     "$q_{1}$"  -> ["varepsilon"] "$q_{8}$" ;
     "$q_{2}$"  -> ["a, b",loop] "$q_{2}$" ;
     "$q_{3}$"  -> ["b"] "$q_{2}$" ;
     "$q_{3}$"  -> ["a"] "$q_{4}$" ;
     "$q_{3}$"  -> [""] "$q_{5}$" ;
     "$q_{4}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{4}$"  -> ["varepsilon"] "$q_{5}$" ;
     "$q_{5}$"  -> ["a"] "$q_{2}$" ;
     "$q_{5}$"  -> [""] "$q_{6}$" ;
     "$q_{5}$"  -> [""] "$q_{7}$" ;
     "$q_{5}$"  -> [""] "$q_{10}$" ;
     "$q_{5}$"  -> ["b"] "$q_{12}$" ;
     "$q_{6}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{6}$"  -> ["varepsilon"] "$q_{7}$" ;
     "$q_{6}$"  -> ["varepsilon"] "$q_{10}$" ;
     "$q_{7}$"  -> ["a"] "$q_{2}$" ;
     "$q_{7}$"  -> [""] "$q_{1}$" ;
     "$q_{7}$"  -> [""] "$q_{3}$" ;
     "$q_{7}$"  -> [""] "$q_{8}$" ;
     "$q_{7}$"  -> [""] "$q_{0}$" ;
     "$q_{7}$"  -> ["b"] "$q_{9}$" [accept];
     "$q_{8}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{8}$"  -> ["varepsilon"] "$q_{3}$" ;
     "$q_{9}$"  -> [""] "$q_{1}$" ;
     "$q_{9}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{9}$"  -> [""] "$q_{3}$" ;
     "$q_{9}$"  -> [""] "$q_{8}$" ;
     "$q_{9}$"  -> ["varepsilon"] "$q_{0}$" ;
     "$q_{10}$"  -> ["b"] "$q_{2}$" ;
     "$q_{10}$"  -> [""] "$q_{1}$" ;
     "$q_{10}$"  -> [""] "$q_{3}$" ;
     "$q_{10}$"  -> [""] "$q_{8}$" ;
     "$q_{10}$"  -> [""] "$q_{0}$" ;
     "$q_{10}$"  -> ["a"] "$q_{11}$" [accept];
     "$q_{11}$"  -> [""] "$q_{1}$" ;
     "$q_{11}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{11}$"  -> [""] "$q_{3}$" ;
     "$q_{11}$"  -> [""] "$q_{8}$" ;
     "$q_{11}$"  -> ["varepsilon"] "$q_{0}$" ;
     "$q_{12}$"  -> ["varepsilon"] "$q_{6}$" ;
     "$q_{12}$"  -> ["a, b"] "$q_{2}$" ;
     "$q_{12}$"  -> [""] "$q_{7}$" ;
     "$q_{12}$"  -> [""] "$q_{10}$" ;
  }
  ; end{scope}
  
  begin{scope} path magicTwo
  graph{
     "$q_{0}$" [initial,accept] -> ["b"] "$q_{1}$" ;
     "$q_{0}$"  -> ["a"] "$q_{2}$" ;
     "$q_{1}$"  -> ["a, b",loop] "$q_{1}$" ;
     "$q_{2}$"  -> ["a"] "$q_{1}$" ;
     "$q_{2}$"  -> ["b"] "$q_{3}$" ;
     "$q_{3}$"  -> ["a"] "$q_{4}$" [accept];
     "$q_{3}$"  -> ["b"] "$q_{5}$" [accept];
     "$q_{4}$"  -> ["b"] "$q_{1}$" ;
     "$q_{4}$"  -> ["a"] "$q_{2}$" ;
     "$q_{5}$"  -> ["b"] "$q_{1}$" ;
     "$q_{5}$"  -> ["a"] "$q_{2}$" ;
  }
  
  ; end{scope}
  
  begin{scope} path magicThree
  graph{
     "$q_{0}$" [initial,accept] -> ["b"] "$q_{1}$" ;
     "$q_{0}$"  -> ["a"] "$q_{2}$" ;
     "$q_{1}$"  -> ["a, b",loop] "$q_{1}$" ;
     "$q_{2}$"  -> ["a"] "$q_{1}$" ;
     "$q_{2}$"  -> ["b"] "$q_{3}$" ;
     "$q_{3}$"  -> ["a, b"] "$q_{0}$" ;
  }
  
  ; end{scope}
  end{tikzpicture}
  
  end{document}
  


Get this bounty!!!

#StackBounty: #tikz-pgf #bar-chart Bar chart with `tikz-pgf` specifying the breakpoints between cells

Bounty: 50

I would like to draw, with tikz-pgf, a bar chart by specifying the breakpoints between histogram cells and the corresponding frequencies. The breakpoints are:

 -1.4 -1.2 -1.0 -0.8 -0.6 -0.4 -0.2  0.0  0.2  0.4  0.6  0.8  1.0  1.2  1.4  1.6

whereas the frequencies:

8    19   106   322  1242  3190  6028 10610  1690  1260   502   160    34     6     1 

For example, between -1.4 and -1.2 we have 8, between -1.2 and -1.0 we have 19 and so on.


Get this bounty!!!

#StackBounty: #tikz-pgf #pgfplots #groupplots #tikz-shape Tikz's custom shape fails when groupplots library is loaded

Bounty: 50

I am using a book documentclass to write a report where I draw some circuit/block schematics using a custom tikz shape called dff that I originally found here and then slightly customised.

Everything works fine until I add tikz‘s groupplots library (for some other plot not shown in the MWE below) to my preamble. Then, my custom shape can no longer be drawn and all I get is a huge amount of "undefined control sequences" and "Package PGF Math" errors that appear to relate to my dff shape but that I cannot make sense of.

The MWE below shows the complete preamble that I used to precisely pinpoint the conflicting command; simply uncomment the line with usepgfplotslibrary{groupplots} to see it fail. Any help or suggestion on how to tackle this issue would be greatly appreciated.

documentclass[a4paper]{book}

usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{amssymb}
usepackage{amsmath}
usepackage{booktabs}
usepackage{float}
usepackage{hyperref}
    defsubfigureautorefname{Fig.}
    deffigureautorefname{Fig.}
usepackage{mathtools}
usepackage{mathdots}
usepackage{multirow}
usepackage{placeins}
usepackage{subfig}
usepackage{xcolor}
%usepackage{tikz}

usepackage[pdftex]{graphicx}
    graphicspath{{./img/}}
    DeclareGraphicsExtensions{.pdf}

usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2#1#3}
usepackage{siunitx}
    sisetup{exponent-product=cdot,detect-all}

usepackage{pgfplots, tikz-3dplot}
usepgfplotslibrary{external}
%usepgfplotslibrary{groupplots}
tikzexternalize[prefix=test-overlaynumber-]
tikzsetexternalprefix{tikzpics/}
usetikzlibrary{3D,
                    calc,%
                    decorations.markings,%
                    decorations.pathreplacing,%
                    external,%
                    positioning,%
                    circuits.logic.mux,%
                    shapes.gates.logic.US,%
                    shapes.geometric}
%tikzset{node distance/.append code={ pgfkeyssetvalue{/tikz/node distance value}{#1} }}   % it's supposed to allow retrieving node distance with pgfkeysvalueof{/tikz/node distance value}
pgfplotsset{compat=newest, table/search path={./dat},scaled ticks=false,%
            every axis/.append style={enlargelimits=false, axis on top,},%
            every mark/.append style={mark size=1pt, mark line=solid},%
            tick label style={font=small, /pgf/number format/fixed}, label style={font=small}, legend style={font=small},%
            xlabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel},%
            ylabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel}}
pgfdeclarelayer{back}
pgfsetlayers{back,main}
usepackage[americaninductors]{circuitikz}

definecolor{mat1}{rgb}{0,0.447,0.7410}
definecolor{mat2}{rgb}{0.8500,0.3250,0.0980}
definecolor{mat3}{rgb}{0.9290,0.6940,0.1250}
definecolor{mat4}{rgb}{0.4940,0.1840,0.5560}

% Rotated Data Flip Flip (DFF) shape
pgfdeclareshape{dff}{
  % The 'minimum width' and 'minimum height' keys, not the content, determine
  % the size
  savedanchornortheast{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=0.5pgf@x
    pgf@y=0.5pgf@y
  }
  % This is redundant, but makes some things easier:
  savedanchorsouthwest{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=-0.5pgf@x
    pgf@y=-0.5pgf@y
  }
  % Inherit from rectangle
  inheritanchorborder[from=rectangle]

  % Define same anchor a normal rectangle has
  anchor{center}{pgfpointorigin}
  anchor{north}{northeast pgf@x=0pt}
  anchor{east}{northeast pgf@y=0pt}
  anchor{south}{southwest pgf@x=0pt}
  anchor{west}{southwest pgf@y=0pt}
  anchor{north east}{northeast}
  anchor{north west}{northeast pgf@x=-pgf@x}
  anchor{south west}{southwest}
  anchor{south east}{southwest pgf@x=-pgf@x}
  anchor{text}{
    pgfpointorigin
    advancepgf@x by -.5wdpgfnodeparttextbox%
    advancepgf@y by -.5htpgfnodeparttextbox%
    advancepgf@y by +.5dppgfnodeparttextbox%
  }

  % Define anchors for signal ports
  anchor{D}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=-pgf@y%
  }
  anchor{CLK}{
    pgf@process{northeast}%
    pgf@x=-1pgf@x%
    pgf@y=0pt%
  }
  anchor{Q}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=pgf@y%
  }
  % Draw the rectangle box and the port labels
  backgroundpath{
    % Rectangle box
    pgfpathrectanglecorners{southwest}{northeast}
    % Angle (>) for clock input
    pgf@anchor@dff@CLK
    pgf@xa=pgf@x pgf@ya=pgf@y
    pgf@xb=pgf@x pgf@yb=pgf@y
    pgf@xc=pgf@x pgf@yc=pgf@y
    pgfmathsetlengthpgf@x{.4ex} % size depends on font size
    advancepgf@ya by pgf@x
    advancepgf@xb by pgf@x
    advancepgf@yc by -pgf@x
    pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
    pgfpathlineto{pgfpoint{pgf@xb}{pgf@yb}}
    pgfpathlineto{pgfpoint{pgf@xc}{pgf@yc}}
    pgfclosepath

    % Draw port labels
    begingroup
    tikzset{flip flop/port labels} % Use font from this style
    tikz@textfont

    endgroup
  }
}

% Key to add font macros to the current font
tikzset{add font/.code={expandafterdefexpandaftertikz@textfontexpandafter{tikz@textfont#1}}} 

% Define default style for this node
tikzset{flip flop/port labels/.style={font=sffamilytiny}}
tikzset{every dff node/.style={draw,minimum width=0.4cm,minimum 
height=0.4cm,inner sep=1mm,outer sep=0pt,cap=round,add 
font=sffamily}}


begin{document}

begin{figure}[t]
centering
begin{tikzpicture}[auto, node distance=4mm and 4mm, circuit logic,every node/.style={font=tiny},]%
    ctikzset{bipoles/thickness=1}
    
    node (data) at (0.5,0.3) [anchor=north]{data};
    node [shape=dff, draw] (ff1) [above=of data] {FF};
end{tikzpicture}
end{figure}

end{document}


Get this bounty!!!

#StackBounty: #tikz-pgf #pgfplots #groupplots #tikz-shape Tikz's custom shape fails when groupplots library is loaded

Bounty: 50

I am using a book documentclass to write a report where I draw some circuit/block schematics using a custom tikz shape called dff that I originally found here and then slightly customised.

Everything works fine until I add tikz‘s groupplots library (for some other plot not shown in the MWE below) to my preamble. Then, my custom shape can no longer be drawn and all I get is a huge amount of "undefined control sequences" and "Package PGF Math" errors that appear to relate to my dff shape but that I cannot make sense of.

The MWE below shows the complete preamble that I used to precisely pinpoint the conflicting command; simply uncomment the line with usepgfplotslibrary{groupplots} to see it fail. Any help or suggestion on how to tackle this issue would be greatly appreciated.

documentclass[a4paper]{book}

usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{amssymb}
usepackage{amsmath}
usepackage{booktabs}
usepackage{float}
usepackage{hyperref}
    defsubfigureautorefname{Fig.}
    deffigureautorefname{Fig.}
usepackage{mathtools}
usepackage{mathdots}
usepackage{multirow}
usepackage{placeins}
usepackage{subfig}
usepackage{xcolor}
%usepackage{tikz}

usepackage[pdftex]{graphicx}
    graphicspath{{./img/}}
    DeclareGraphicsExtensions{.pdf}

usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2#1#3}
usepackage{siunitx}
    sisetup{exponent-product=cdot,detect-all}

usepackage{pgfplots, tikz-3dplot}
usepgfplotslibrary{external}
%usepgfplotslibrary{groupplots}
tikzexternalize[prefix=test-overlaynumber-]
tikzsetexternalprefix{tikzpics/}
usetikzlibrary{3D,
                    calc,%
                    decorations.markings,%
                    decorations.pathreplacing,%
                    external,%
                    positioning,%
                    circuits.logic.mux,%
                    shapes.gates.logic.US,%
                    shapes.geometric}
%tikzset{node distance/.append code={ pgfkeyssetvalue{/tikz/node distance value}{#1} }}   % it's supposed to allow retrieving node distance with pgfkeysvalueof{/tikz/node distance value}
pgfplotsset{compat=newest, table/search path={./dat},scaled ticks=false,%
            every axis/.append style={enlargelimits=false, axis on top,},%
            every mark/.append style={mark size=1pt, mark line=solid},%
            tick label style={font=small, /pgf/number format/fixed}, label style={font=small}, legend style={font=small},%
            xlabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel},%
            ylabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel}}
pgfdeclarelayer{back}
pgfsetlayers{back,main}
usepackage[americaninductors]{circuitikz}

definecolor{mat1}{rgb}{0,0.447,0.7410}
definecolor{mat2}{rgb}{0.8500,0.3250,0.0980}
definecolor{mat3}{rgb}{0.9290,0.6940,0.1250}
definecolor{mat4}{rgb}{0.4940,0.1840,0.5560}

% Rotated Data Flip Flip (DFF) shape
pgfdeclareshape{dff}{
  % The 'minimum width' and 'minimum height' keys, not the content, determine
  % the size
  savedanchornortheast{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=0.5pgf@x
    pgf@y=0.5pgf@y
  }
  % This is redundant, but makes some things easier:
  savedanchorsouthwest{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=-0.5pgf@x
    pgf@y=-0.5pgf@y
  }
  % Inherit from rectangle
  inheritanchorborder[from=rectangle]

  % Define same anchor a normal rectangle has
  anchor{center}{pgfpointorigin}
  anchor{north}{northeast pgf@x=0pt}
  anchor{east}{northeast pgf@y=0pt}
  anchor{south}{southwest pgf@x=0pt}
  anchor{west}{southwest pgf@y=0pt}
  anchor{north east}{northeast}
  anchor{north west}{northeast pgf@x=-pgf@x}
  anchor{south west}{southwest}
  anchor{south east}{southwest pgf@x=-pgf@x}
  anchor{text}{
    pgfpointorigin
    advancepgf@x by -.5wdpgfnodeparttextbox%
    advancepgf@y by -.5htpgfnodeparttextbox%
    advancepgf@y by +.5dppgfnodeparttextbox%
  }

  % Define anchors for signal ports
  anchor{D}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=-pgf@y%
  }
  anchor{CLK}{
    pgf@process{northeast}%
    pgf@x=-1pgf@x%
    pgf@y=0pt%
  }
  anchor{Q}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=pgf@y%
  }
  % Draw the rectangle box and the port labels
  backgroundpath{
    % Rectangle box
    pgfpathrectanglecorners{southwest}{northeast}
    % Angle (>) for clock input
    pgf@anchor@dff@CLK
    pgf@xa=pgf@x pgf@ya=pgf@y
    pgf@xb=pgf@x pgf@yb=pgf@y
    pgf@xc=pgf@x pgf@yc=pgf@y
    pgfmathsetlengthpgf@x{.4ex} % size depends on font size
    advancepgf@ya by pgf@x
    advancepgf@xb by pgf@x
    advancepgf@yc by -pgf@x
    pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
    pgfpathlineto{pgfpoint{pgf@xb}{pgf@yb}}
    pgfpathlineto{pgfpoint{pgf@xc}{pgf@yc}}
    pgfclosepath

    % Draw port labels
    begingroup
    tikzset{flip flop/port labels} % Use font from this style
    tikz@textfont

    endgroup
  }
}

% Key to add font macros to the current font
tikzset{add font/.code={expandafterdefexpandaftertikz@textfontexpandafter{tikz@textfont#1}}} 

% Define default style for this node
tikzset{flip flop/port labels/.style={font=sffamilytiny}}
tikzset{every dff node/.style={draw,minimum width=0.4cm,minimum 
height=0.4cm,inner sep=1mm,outer sep=0pt,cap=round,add 
font=sffamily}}


begin{document}

begin{figure}[t]
centering
begin{tikzpicture}[auto, node distance=4mm and 4mm, circuit logic,every node/.style={font=tiny},]%
    ctikzset{bipoles/thickness=1}
    
    node (data) at (0.5,0.3) [anchor=north]{data};
    node [shape=dff, draw] (ff1) [above=of data] {FF};
end{tikzpicture}
end{figure}

end{document}


Get this bounty!!!

#StackBounty: #tikz-pgf #pgfplots #groupplots #tikz-shape Tikz's custom shape fails when groupplots library is loaded

Bounty: 50

I am using a book documentclass to write a report where I draw some circuit/block schematics using a custom tikz shape called dff that I originally found here and then slightly customised.

Everything works fine until I add tikz‘s groupplots library (for some other plot not shown in the MWE below) to my preamble. Then, my custom shape can no longer be drawn and all I get is a huge amount of "undefined control sequences" and "Package PGF Math" errors that appear to relate to my dff shape but that I cannot make sense of.

The MWE below shows the complete preamble that I used to precisely pinpoint the conflicting command; simply uncomment the line with usepgfplotslibrary{groupplots} to see it fail. Any help or suggestion on how to tackle this issue would be greatly appreciated.

documentclass[a4paper]{book}

usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{amssymb}
usepackage{amsmath}
usepackage{booktabs}
usepackage{float}
usepackage{hyperref}
    defsubfigureautorefname{Fig.}
    deffigureautorefname{Fig.}
usepackage{mathtools}
usepackage{mathdots}
usepackage{multirow}
usepackage{placeins}
usepackage{subfig}
usepackage{xcolor}
%usepackage{tikz}

usepackage[pdftex]{graphicx}
    graphicspath{{./img/}}
    DeclareGraphicsExtensions{.pdf}

usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2#1#3}
usepackage{siunitx}
    sisetup{exponent-product=cdot,detect-all}

usepackage{pgfplots, tikz-3dplot}
usepgfplotslibrary{external}
%usepgfplotslibrary{groupplots}
tikzexternalize[prefix=test-overlaynumber-]
tikzsetexternalprefix{tikzpics/}
usetikzlibrary{3D,
                    calc,%
                    decorations.markings,%
                    decorations.pathreplacing,%
                    external,%
                    positioning,%
                    circuits.logic.mux,%
                    shapes.gates.logic.US,%
                    shapes.geometric}
%tikzset{node distance/.append code={ pgfkeyssetvalue{/tikz/node distance value}{#1} }}   % it's supposed to allow retrieving node distance with pgfkeysvalueof{/tikz/node distance value}
pgfplotsset{compat=newest, table/search path={./dat},scaled ticks=false,%
            every axis/.append style={enlargelimits=false, axis on top,},%
            every mark/.append style={mark size=1pt, mark line=solid},%
            tick label style={font=small, /pgf/number format/fixed}, label style={font=small}, legend style={font=small},%
            xlabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel},%
            ylabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel}}
pgfdeclarelayer{back}
pgfsetlayers{back,main}
usepackage[americaninductors]{circuitikz}

definecolor{mat1}{rgb}{0,0.447,0.7410}
definecolor{mat2}{rgb}{0.8500,0.3250,0.0980}
definecolor{mat3}{rgb}{0.9290,0.6940,0.1250}
definecolor{mat4}{rgb}{0.4940,0.1840,0.5560}

% Rotated Data Flip Flip (DFF) shape
pgfdeclareshape{dff}{
  % The 'minimum width' and 'minimum height' keys, not the content, determine
  % the size
  savedanchornortheast{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=0.5pgf@x
    pgf@y=0.5pgf@y
  }
  % This is redundant, but makes some things easier:
  savedanchorsouthwest{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=-0.5pgf@x
    pgf@y=-0.5pgf@y
  }
  % Inherit from rectangle
  inheritanchorborder[from=rectangle]

  % Define same anchor a normal rectangle has
  anchor{center}{pgfpointorigin}
  anchor{north}{northeast pgf@x=0pt}
  anchor{east}{northeast pgf@y=0pt}
  anchor{south}{southwest pgf@x=0pt}
  anchor{west}{southwest pgf@y=0pt}
  anchor{north east}{northeast}
  anchor{north west}{northeast pgf@x=-pgf@x}
  anchor{south west}{southwest}
  anchor{south east}{southwest pgf@x=-pgf@x}
  anchor{text}{
    pgfpointorigin
    advancepgf@x by -.5wdpgfnodeparttextbox%
    advancepgf@y by -.5htpgfnodeparttextbox%
    advancepgf@y by +.5dppgfnodeparttextbox%
  }

  % Define anchors for signal ports
  anchor{D}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=-pgf@y%
  }
  anchor{CLK}{
    pgf@process{northeast}%
    pgf@x=-1pgf@x%
    pgf@y=0pt%
  }
  anchor{Q}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=pgf@y%
  }
  % Draw the rectangle box and the port labels
  backgroundpath{
    % Rectangle box
    pgfpathrectanglecorners{southwest}{northeast}
    % Angle (>) for clock input
    pgf@anchor@dff@CLK
    pgf@xa=pgf@x pgf@ya=pgf@y
    pgf@xb=pgf@x pgf@yb=pgf@y
    pgf@xc=pgf@x pgf@yc=pgf@y
    pgfmathsetlengthpgf@x{.4ex} % size depends on font size
    advancepgf@ya by pgf@x
    advancepgf@xb by pgf@x
    advancepgf@yc by -pgf@x
    pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
    pgfpathlineto{pgfpoint{pgf@xb}{pgf@yb}}
    pgfpathlineto{pgfpoint{pgf@xc}{pgf@yc}}
    pgfclosepath

    % Draw port labels
    begingroup
    tikzset{flip flop/port labels} % Use font from this style
    tikz@textfont

    endgroup
  }
}

% Key to add font macros to the current font
tikzset{add font/.code={expandafterdefexpandaftertikz@textfontexpandafter{tikz@textfont#1}}} 

% Define default style for this node
tikzset{flip flop/port labels/.style={font=sffamilytiny}}
tikzset{every dff node/.style={draw,minimum width=0.4cm,minimum 
height=0.4cm,inner sep=1mm,outer sep=0pt,cap=round,add 
font=sffamily}}


begin{document}

begin{figure}[t]
centering
begin{tikzpicture}[auto, node distance=4mm and 4mm, circuit logic,every node/.style={font=tiny},]%
    ctikzset{bipoles/thickness=1}
    
    node (data) at (0.5,0.3) [anchor=north]{data};
    node [shape=dff, draw] (ff1) [above=of data] {FF};
end{tikzpicture}
end{figure}

end{document}


Get this bounty!!!

#StackBounty: #tikz-pgf #pgfplots #groupplots #tikz-shape Tikz's custom shape fails when groupplots library is loaded

Bounty: 50

I am using a book documentclass to write a report where I draw some circuit/block schematics using a custom tikz shape called dff that I originally found here and then slightly customised.

Everything works fine until I add tikz‘s groupplots library (for some other plot not shown in the MWE below) to my preamble. Then, my custom shape can no longer be drawn and all I get is a huge amount of "undefined control sequences" and "Package PGF Math" errors that appear to relate to my dff shape but that I cannot make sense of.

The MWE below shows the complete preamble that I used to precisely pinpoint the conflicting command; simply uncomment the line with usepgfplotslibrary{groupplots} to see it fail. Any help or suggestion on how to tackle this issue would be greatly appreciated.

documentclass[a4paper]{book}

usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{amssymb}
usepackage{amsmath}
usepackage{booktabs}
usepackage{float}
usepackage{hyperref}
    defsubfigureautorefname{Fig.}
    deffigureautorefname{Fig.}
usepackage{mathtools}
usepackage{mathdots}
usepackage{multirow}
usepackage{placeins}
usepackage{subfig}
usepackage{xcolor}
%usepackage{tikz}

usepackage[pdftex]{graphicx}
    graphicspath{{./img/}}
    DeclareGraphicsExtensions{.pdf}

usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2#1#3}
usepackage{siunitx}
    sisetup{exponent-product=cdot,detect-all}

usepackage{pgfplots, tikz-3dplot}
usepgfplotslibrary{external}
%usepgfplotslibrary{groupplots}
tikzexternalize[prefix=test-overlaynumber-]
tikzsetexternalprefix{tikzpics/}
usetikzlibrary{3D,
                    calc,%
                    decorations.markings,%
                    decorations.pathreplacing,%
                    external,%
                    positioning,%
                    circuits.logic.mux,%
                    shapes.gates.logic.US,%
                    shapes.geometric}
%tikzset{node distance/.append code={ pgfkeyssetvalue{/tikz/node distance value}{#1} }}   % it's supposed to allow retrieving node distance with pgfkeysvalueof{/tikz/node distance value}
pgfplotsset{compat=newest, table/search path={./dat},scaled ticks=false,%
            every axis/.append style={enlargelimits=false, axis on top,},%
            every mark/.append style={mark size=1pt, mark line=solid},%
            tick label style={font=small, /pgf/number format/fixed}, label style={font=small}, legend style={font=small},%
            xlabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel},%
            ylabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel}}
pgfdeclarelayer{back}
pgfsetlayers{back,main}
usepackage[americaninductors]{circuitikz}

definecolor{mat1}{rgb}{0,0.447,0.7410}
definecolor{mat2}{rgb}{0.8500,0.3250,0.0980}
definecolor{mat3}{rgb}{0.9290,0.6940,0.1250}
definecolor{mat4}{rgb}{0.4940,0.1840,0.5560}

% Rotated Data Flip Flip (DFF) shape
pgfdeclareshape{dff}{
  % The 'minimum width' and 'minimum height' keys, not the content, determine
  % the size
  savedanchornortheast{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=0.5pgf@x
    pgf@y=0.5pgf@y
  }
  % This is redundant, but makes some things easier:
  savedanchorsouthwest{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=-0.5pgf@x
    pgf@y=-0.5pgf@y
  }
  % Inherit from rectangle
  inheritanchorborder[from=rectangle]

  % Define same anchor a normal rectangle has
  anchor{center}{pgfpointorigin}
  anchor{north}{northeast pgf@x=0pt}
  anchor{east}{northeast pgf@y=0pt}
  anchor{south}{southwest pgf@x=0pt}
  anchor{west}{southwest pgf@y=0pt}
  anchor{north east}{northeast}
  anchor{north west}{northeast pgf@x=-pgf@x}
  anchor{south west}{southwest}
  anchor{south east}{southwest pgf@x=-pgf@x}
  anchor{text}{
    pgfpointorigin
    advancepgf@x by -.5wdpgfnodeparttextbox%
    advancepgf@y by -.5htpgfnodeparttextbox%
    advancepgf@y by +.5dppgfnodeparttextbox%
  }

  % Define anchors for signal ports
  anchor{D}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=-pgf@y%
  }
  anchor{CLK}{
    pgf@process{northeast}%
    pgf@x=-1pgf@x%
    pgf@y=0pt%
  }
  anchor{Q}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=pgf@y%
  }
  % Draw the rectangle box and the port labels
  backgroundpath{
    % Rectangle box
    pgfpathrectanglecorners{southwest}{northeast}
    % Angle (>) for clock input
    pgf@anchor@dff@CLK
    pgf@xa=pgf@x pgf@ya=pgf@y
    pgf@xb=pgf@x pgf@yb=pgf@y
    pgf@xc=pgf@x pgf@yc=pgf@y
    pgfmathsetlengthpgf@x{.4ex} % size depends on font size
    advancepgf@ya by pgf@x
    advancepgf@xb by pgf@x
    advancepgf@yc by -pgf@x
    pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
    pgfpathlineto{pgfpoint{pgf@xb}{pgf@yb}}
    pgfpathlineto{pgfpoint{pgf@xc}{pgf@yc}}
    pgfclosepath

    % Draw port labels
    begingroup
    tikzset{flip flop/port labels} % Use font from this style
    tikz@textfont

    endgroup
  }
}

% Key to add font macros to the current font
tikzset{add font/.code={expandafterdefexpandaftertikz@textfontexpandafter{tikz@textfont#1}}} 

% Define default style for this node
tikzset{flip flop/port labels/.style={font=sffamilytiny}}
tikzset{every dff node/.style={draw,minimum width=0.4cm,minimum 
height=0.4cm,inner sep=1mm,outer sep=0pt,cap=round,add 
font=sffamily}}


begin{document}

begin{figure}[t]
centering
begin{tikzpicture}[auto, node distance=4mm and 4mm, circuit logic,every node/.style={font=tiny},]%
    ctikzset{bipoles/thickness=1}
    
    node (data) at (0.5,0.3) [anchor=north]{data};
    node [shape=dff, draw] (ff1) [above=of data] {FF};
end{tikzpicture}
end{figure}

end{document}


Get this bounty!!!

#StackBounty: #tikz-pgf #pgfplots #groupplots #tikz-shape Tikz's custom shape fails when groupplots library is loaded

Bounty: 50

I am using a book documentclass to write a report where I draw some circuit/block schematics using a custom tikz shape called dff that I originally found here and then slightly customised.

Everything works fine until I add tikz‘s groupplots library (for some other plot not shown in the MWE below) to my preamble. Then, my custom shape can no longer be drawn and all I get is a huge amount of "undefined control sequences" and "Package PGF Math" errors that appear to relate to my dff shape but that I cannot make sense of.

The MWE below shows the complete preamble that I used to precisely pinpoint the conflicting command; simply uncomment the line with usepgfplotslibrary{groupplots} to see it fail. Any help or suggestion on how to tackle this issue would be greatly appreciated.

documentclass[a4paper]{book}

usepackage[english]{babel}
usepackage[utf8]{inputenc}
usepackage{amssymb}
usepackage{amsmath}
usepackage{booktabs}
usepackage{float}
usepackage{hyperref}
    defsubfigureautorefname{Fig.}
    deffigureautorefname{Fig.}
usepackage{mathtools}
usepackage{mathdots}
usepackage{multirow}
usepackage{placeins}
usepackage{subfig}
usepackage{xcolor}
%usepackage{tikz}

usepackage[pdftex]{graphicx}
    graphicspath{{./img/}}
    DeclareGraphicsExtensions{.pdf}

usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2#1#3}
usepackage{siunitx}
    sisetup{exponent-product=cdot,detect-all}

usepackage{pgfplots, tikz-3dplot}
usepgfplotslibrary{external}
%usepgfplotslibrary{groupplots}
tikzexternalize[prefix=test-overlaynumber-]
tikzsetexternalprefix{tikzpics/}
usetikzlibrary{3D,
                    calc,%
                    decorations.markings,%
                    decorations.pathreplacing,%
                    external,%
                    positioning,%
                    circuits.logic.mux,%
                    shapes.gates.logic.US,%
                    shapes.geometric}
%tikzset{node distance/.append code={ pgfkeyssetvalue{/tikz/node distance value}{#1} }}   % it's supposed to allow retrieving node distance with pgfkeysvalueof{/tikz/node distance value}
pgfplotsset{compat=newest, table/search path={./dat},scaled ticks=false,%
            every axis/.append style={enlargelimits=false, axis on top,},%
            every mark/.append style={mark size=1pt, mark line=solid},%
            tick label style={font=small, /pgf/number format/fixed}, label style={font=small}, legend style={font=small},%
            xlabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel},%
            ylabel style={at={(ticklabel cs:0.5,-5pt)},anchor=near ticklabel}}
pgfdeclarelayer{back}
pgfsetlayers{back,main}
usepackage[americaninductors]{circuitikz}

definecolor{mat1}{rgb}{0,0.447,0.7410}
definecolor{mat2}{rgb}{0.8500,0.3250,0.0980}
definecolor{mat3}{rgb}{0.9290,0.6940,0.1250}
definecolor{mat4}{rgb}{0.4940,0.1840,0.5560}

% Rotated Data Flip Flip (DFF) shape
pgfdeclareshape{dff}{
  % The 'minimum width' and 'minimum height' keys, not the content, determine
  % the size
  savedanchornortheast{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=0.5pgf@x
    pgf@y=0.5pgf@y
  }
  % This is redundant, but makes some things easier:
  savedanchorsouthwest{%
    pgfmathsetlengthpgf@x{pgfshapeminwidth}%
    pgfmathsetlengthpgf@y{pgfshapeminheight}%
    pgf@x=-0.5pgf@x
    pgf@y=-0.5pgf@y
  }
  % Inherit from rectangle
  inheritanchorborder[from=rectangle]

  % Define same anchor a normal rectangle has
  anchor{center}{pgfpointorigin}
  anchor{north}{northeast pgf@x=0pt}
  anchor{east}{northeast pgf@y=0pt}
  anchor{south}{southwest pgf@x=0pt}
  anchor{west}{southwest pgf@y=0pt}
  anchor{north east}{northeast}
  anchor{north west}{northeast pgf@x=-pgf@x}
  anchor{south west}{southwest}
  anchor{south east}{southwest pgf@x=-pgf@x}
  anchor{text}{
    pgfpointorigin
    advancepgf@x by -.5wdpgfnodeparttextbox%
    advancepgf@y by -.5htpgfnodeparttextbox%
    advancepgf@y by +.5dppgfnodeparttextbox%
  }

  % Define anchors for signal ports
  anchor{D}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=-pgf@y%
  }
  anchor{CLK}{
    pgf@process{northeast}%
    pgf@x=-1pgf@x%
    pgf@y=0pt%
  }
  anchor{Q}{
    pgf@process{northeast}%
    pgf@x=0pt%
    pgf@y=pgf@y%
  }
  % Draw the rectangle box and the port labels
  backgroundpath{
    % Rectangle box
    pgfpathrectanglecorners{southwest}{northeast}
    % Angle (>) for clock input
    pgf@anchor@dff@CLK
    pgf@xa=pgf@x pgf@ya=pgf@y
    pgf@xb=pgf@x pgf@yb=pgf@y
    pgf@xc=pgf@x pgf@yc=pgf@y
    pgfmathsetlengthpgf@x{.4ex} % size depends on font size
    advancepgf@ya by pgf@x
    advancepgf@xb by pgf@x
    advancepgf@yc by -pgf@x
    pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
    pgfpathlineto{pgfpoint{pgf@xb}{pgf@yb}}
    pgfpathlineto{pgfpoint{pgf@xc}{pgf@yc}}
    pgfclosepath

    % Draw port labels
    begingroup
    tikzset{flip flop/port labels} % Use font from this style
    tikz@textfont

    endgroup
  }
}

% Key to add font macros to the current font
tikzset{add font/.code={expandafterdefexpandaftertikz@textfontexpandafter{tikz@textfont#1}}} 

% Define default style for this node
tikzset{flip flop/port labels/.style={font=sffamilytiny}}
tikzset{every dff node/.style={draw,minimum width=0.4cm,minimum 
height=0.4cm,inner sep=1mm,outer sep=0pt,cap=round,add 
font=sffamily}}


begin{document}

begin{figure}[t]
centering
begin{tikzpicture}[auto, node distance=4mm and 4mm, circuit logic,every node/.style={font=tiny},]%
    ctikzset{bipoles/thickness=1}
    
    node (data) at (0.5,0.3) [anchor=north]{data};
    node [shape=dff, draw] (ff1) [above=of data] {FF};
end{tikzpicture}
end{figure}

end{document}


Get this bounty!!!