On 12/6/2021 6:39 PM, Aditya Mahajan via ntg-context wrote:
On Mon, 6 Dec 2021, Aditya Mahajan via ntg-context wrote:

Something is still not working correctly though. With the simple example that 
Hans sent, I get error messages:

tex error       > tex error on line 76 in file m-circuitikz.mkxl: Package 
pgfkeys Error: I do not know the key '/tikz/resistor', to which you passed 
'american', and I am going to ignore it. Perhaps you misspelled it

which are weird because tikz is looking at keys tikz/resistor rather than 
tikz/circuittikz/resistor. But I don't understand why this is the case.

Here is a minimal example to show the error.

\usemodule[m][tikz]

\tikzinputfile{pgfcirc.defines.tex}
\tikzinputfile{pgfcircbipoles.tex}

\starttext
\bgroup
\loggingall
\ctikzset{resistor=american}
\egroup
\stoptext

which gives the error

tex error       > tex error on line 10 in file ./t2.tex: Package pgfkeys Error: 
I do not know the key '/tikz/resistor', to which you passed 'american', and I am 
going to ignore it. Perhaps you misspelled it

different error here ... i need to load more files

The file pgfcirc.defines.tex has:

\def\circuitikzbasekey{/tikz/circuitikz}
\pgfkeys{\circuitikzbasekey/.is family}
\def\circuitikzset{\expandafter\pgfqkeys\expandafter{\circuitikzbasekey}}
\let\ctikzset\circuitikzset


The file pgfcircbipoles.tex has the code:

\newif\ifpgf@circuit@europeanresistor
\ctikzset{resistor/.is choice}
\ctikzset{resistor/american/.code = \pgf@circuit@europeanresistorfalse }
\ctikzset{resistor/european/.code = \pgf@circuit@europeanresistortrue }
\tikzset{american resistors/.style = {\circuitikzbasekey/resistor = american}}
\tikzset{european resistors/.style = {\circuitikzbasekey/resistor = european}}%

So, the key which is defined is \circuitikzbasekey/resistor. Not sure why 
pgfkeys is searching for tikz/resistor.

don't worry ... i'm even less sure ... one needs a bit different mindset for that kind of tex code (all can be fixed i guess but when it's not context specific it makes more sense to let the maintainer do it)

ths only difference wrt tikz between mkiv and mkxl is that we have different defaults wrt par handling (afaik both have the same catcode settings here) and i don't think tikz uses anything low level context

@Hans, does the above code work correctly for you? If so, then we can wait 
until the next upload and test again.
with the attached:

\usemodule[m][circuitikz]

\starttext
\starttikzsettings % to be sure
\ctikzset{resistor=american}
\stoptikzsettings
\stoptext

that works (tons of files loaded) here but nothing graphic

(for those whio try: make sure that the t-* variants are gone)

i see it loading other t-* files so maybe we should more that code to the m-* files too ... easier to maintain that way .. and if we have a few (not too slow) test files in the test suite it's easier to see when / why something fails

if it doesn't at your end we need to define 'how to install the right (circuit)tikz stuff' and 'from where'

(btw, does it all work ok in mkiv? after all, that hasn't changed for a while)

Hans


Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
%D \module
%D   [       file=m-tikz,
%D        version=2021.07.12,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=TIKZ support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D A fixed variant of the t-tikz module distributed with tikz. For
%D practical reasons per 2021 we split the module for \MKIV\ and
%D \LMTX. (Maybe some day I'll optimize TIKZ a bit.)

\ifdefined\pdflastxpos \else
    \unprotect
        
\frozen\overloaded\protected\def\pdflastxpos{\numexpr\clf_lastxpos\relax}
        
\frozen\overloaded\protected\def\pdflastypos{\numexpr\clf_lastypos\relax}
    \protect
\fi

\permanent\protected\def\starttikzinput
  {\pushoverloadmode
   \pushcatcodetable
   \setcatcodetable\texcatcodes
   \unprotect
   \catcode`\@=11
   \catcode`\|=12
   \catcode`\!=12
   \autoparagraphmode\zerocount}

\permanent\protected\def\stoptikzinput
  {\autoparagraphmode\plusone
   \protect
   \popcatcodetable
   \popoverloadmode}

\permanent\protected\def\tikzinputfile#1%
  {\starttikzinput
   \input{#1}\relax
   \stoptikzinput}

\tikzinputfile{t-pgf.tex}
\tikzinputfile{t-pgffor.tex}
\tikzinputfile{tikz.code.tex}

\permanent\protected\def\tikzerrormessage#1#2#3%
  {\writestatus{#1}{#2}}

% For now we need this but we need to educate the user to wrap settings in the
% wrappers. So some day the next line will go. I need to check what commands are
% possible outside a picture.

\overloadmode\zerocount

\permanent\protected\def\starttikzsettings
  {\pushoverloadmode
   \autoparagraphmode\zerocount}

\permanent\protected\def\stoptikzsettings
  {\autoparagraphmode\plusone
   \popoverloadmode}

\permanent\protected\def\starttikzpicture
  {\dontleavehmode
   \hcontainer\bgroup
   \autoparagraphmode\zerocount
 % \pushoverloadmode
   \ifdefined\PackageError\else \let\PackageError\tikzerrormessage \fi
   \tikzpicture}

\permanent\protected\def\stoptikzpicture
  {\endtikzpicture
 % \popoverloadmode
   \egroup}

\ifx\pgfdefined\undefined

    \let\pgfdefined\relax

    \ifx\pgfcoredefined\undefined

        \let\pgfcoredefined\relax

        \tikzinputfile{pgfsys.code.tex}
        \tikzinputfile{pgfsyssoftpath.code.tex}
        \tikzinputfile{pgfsysprotocol.code.tex}
        \tikzinputfile{pgfcore.code.tex}

        \let\startpgfpicture             \pgfpicture              
\let\stoppgfpicture            \endpgfpicture
        \let\startpgfscope               \pgfscope                
\let\stoppgfscope              \endpgfscope
        \let\startpgflowlevelscope       \pgflowlevelscope        
\let\stoppgflowlevelscope      \endpgflowlevelscope
        \let\startpgfinterruptpath       \pgfinterruptpath        
\let\stoppgfinterruptpath      \endpgfinterruptpath
        \let\startpgfinterruptpicture    \pgfinterruptpicture     
\let\stoppgfinterruptpicture   \endpgfinterruptpicture
        \let\startpgfinterruptboundingbox\pgfinterruptboundinbox  
\let\stoppgfinterruptboudingbox\endpgfinterruptboundingbox

    \fi

    \let\normalusepgfmodule\usepgfmodule

    \protected\def\usepgfmodule[#1]%
      {\starttikzinput
       \normalusepgfmodule[#1]%
       \stoptikzinput}

    \usepgfmodule[shapes,plot]

\fi

\stopmodule
%D \module
%D   [       file=m-circuitikz,
%D        version=2021.12.03,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=CURCUITIKZ support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D A fixed variant of the t-curcuitikz module distributed with tikz. This one
%D is for \LMTX.

\usemodule[m][tikz]

\startmodule[circuitikz]

\def\pgfcircversion     {1.4.4}
\def\pgfcircversiondate {2021/10/31}

\usetikzlibrary[calc]
\usetikzlibrary[arrows.meta, bending]
\usetikzlibrary[fpu] % may be needed for use fpu reciprocal (v1.0.1)

\tikzinputfile{pgfcirc.defines.tex}
\tikzinputfile{pgfcircutils.tex}
\tikzinputfile{pgfcircpath.tex}

\tikzinputfile{pgfcircshapes.tex}
\tikzinputfile{pgfcircmonopoles.tex}
\tikzinputfile{pgfcircbipoles.tex}
\tikzinputfile{pgfcirctripoles.tex}
\tikzinputfile{pgfcircquadpoles.tex}
\tikzinputfile{pgfcircmultipoles.tex}

\tikzinputfile{pgfcirclabel.tex}
\tikzinputfile{pgfcircvoltage.tex}
\tikzinputfile{pgfcirccurrent.tex}
\tikzinputfile{pgfcircflow.tex}

% defaults

\setupmodule
  [current=european,
   voltage=european,
   resistor=american,
   inductor=cute,
   logic=american,
   siunitx=true,
   arrowmos=false]

% can be done nicer ... todo

\processaction
  [\currentmoduleparameter{voltage}]
  [european=>\ctikzset{voltage=european},
   american=>\ctikzset{voltage=american}]

\processaction
  [\currentmoduleparameter{current}]
  [european=>\ctikzset{ current=european},
   american=>\ctikzset{ current=american}]

\processaction
  [\currentmoduleparameter{label}]
  [straight=>\ctikzset{label/align = straight},
   align=>\ctikzset{label/align = rotate},
   smart=>\ctikzset{label/align = smart}]

\processaction
  [\currentmoduleparameter{resistor}]
  [european=>\ctikzset{ resistor=european},
   american=>\ctikzset{ resistor=american}]

\processaction
  [\currentmoduleparameter{inductor}]
  [european=>\ctikzset{ inductor=european},
   american=>\ctikzset{ inductor=american},
   cute=>\ctikzset{ inductor=cute}]

\processaction
  [\currentmoduleparameter{diode}]
  [full=>\ctikzset{ diode=full},
   empty=>\ctikzset{ diode=empty}]

\processaction
  [\currentmoduleparameter{logic}]
  [european=>\ctikzset{ logic ports=european},
   american=>\ctikzset{ logic ports=american}]

% hm, we have units built in and in mkii one can load the units module
% ... always been so ...

\processaction
  [\currentmoduleparameter{siunitx}]
  [true=>\def\SI    #1#2{#1\,#2}
         \def\ampere    {\rm{A}}
         \def\volt      {\rm{V}}
         \def\ohm       {\Omega}
         \def\siemens   {\rm{S}}
         \def\farad     {\rm{F}}
         \def\henry     {\rm{H}}
         \def\second    {\rm{s}}
         \def\coulomb   {\rm{C}}
         \def\siemens   {\rm{S}}
         \def\radians   {\rm{rad}}
         \def\milli     {\rm{m}}
         \def\micro     {\mu}
         \def\nano      {\rm{n}}
         \def\pico      {\rm{p}}
         \def\kilo      {\rm{k}}
         \def\mega      {\rm{M}}
         \def\giga      {\rm{G}}
         \def\tera      {\rm{T}}]

\unprotect

\processaction
  [\currentmoduleparameter{arrowmos}]
  [true=>\pgf@circuit@mos@arrowstrue,
   false=>\pgf@circuit@mos@arrowsfalse]

\protect

\ctikzset{tripoles/op amp/font/.initial=\switchtobodyfont[small]}

\aliased\let\stopcircuitikz\relax

\permanent\protected\def\startcircuitikz#1\stopcircuitikz
  {\starttikzpicture#1\stoptikzpicture}

\stopmodule

\endinput
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to