How to add a particular object to an `ocg` list The Next CEO of Stack OverflowChecking whether or not a node has been previously definedHow to draw a diagram of custom subject correlativitiesDesign an algorithm capable of predicting collisions to choose alternative path using `tikzpicture` environmentHow to connect `pic`s through a set of colorful arrows using `tikzpicture` environmentHow to put a box and use columns to separate arrowsAlignment of TikZ objectHow to add label to a 'copy shadow' of an object?Bend 3D cylindrical objectTikZ/ERD: node (=Entity) label on the insidedebugging tikz: how assign each separate tikz object to a variable and then add them to a picture?Redefine object inside a loopDrawing solid object by TikzMultiple choice questions linked to solutions using Optional Content Groups (OCG)How to draw “particular” arrow in TikzIs there a bug with the `switch ocg with mark on` key of the ocgx and ocgx2 packages?

Is a linearly independent set whose span is dense a Schauder basis?

Car headlights in a world without electricity

How to find if SQL server backup is encrypted with TDE without restoring the backup

Find a path from s to t using as few red nodes as possible

Early programmable calculators with RS-232

Does Germany produce more waste than the US?

Is it possible to create a QR code using text?

It it possible to avoid kiwi.com's automatic online check-in and instead do it manually by yourself?

How can I prove that a state of equilibrium is unstable?

Creating a script with console commands

Compensation for working overtime on Saturdays

How do I keep Mac Emacs from trapping M-`?

How to pronounce fünf in 45

Gauss' Posthumous Publications?

Salesforce opportunity stages

Incomplete cube

How to unfasten electrical subpanel attached with ramset

How can a day be of 24 hours?

Does int main() need a declaration on C++?

Are British MPs missing the point, with these 'Indicative Votes'?

Strange use of "whether ... than ..." in official text

How do I secure a TV wall mount?

Is a distribution that is normal, but highly skewed, considered Gaussian?

Calculating discount not working



How to add a particular object to an `ocg` list



The Next CEO of Stack OverflowChecking whether or not a node has been previously definedHow to draw a diagram of custom subject correlativitiesDesign an algorithm capable of predicting collisions to choose alternative path using `tikzpicture` environmentHow to connect `pic`s through a set of colorful arrows using `tikzpicture` environmentHow to put a box and use columns to separate arrowsAlignment of TikZ objectHow to add label to a 'copy shadow' of an object?Bend 3D cylindrical objectTikZ/ERD: node (=Entity) label on the insidedebugging tikz: how assign each separate tikz object to a variable and then add them to a picture?Redefine object inside a loopDrawing solid object by TikzMultiple choice questions linked to solutions using Optional Content Groups (OCG)How to draw “particular” arrow in TikzIs there a bug with the `switch ocg with mark on` key of the ocgx and ocgx2 packages?










0















This is an addendum of a previous question: How to put a box and use columns to separate arrows.



Please consider this MWE (adapted from a nice answer of that question):



documentclassarticle
usepackage[margin=0in,footskip=0in]geometry
usepackage[english]babel
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagehyperref
usepackage[tikz]ocgx2
usepackageamssymb % checkmark
% check box command for layer switching
newcommandlayerCheckBox[3]%
% #1: switch id, if empty use #2 instead
% #2: layer ids to be toggled (space separated if multiple ids),
% #3: initial visibility
resizebox2ex!%
ooalign%
switchocg#1 #2$square$cr%
beginocg%
ifxnil#1nil#2else#1fi%
%
%
ifxnil#1nil#2else#1fi%
#3$checkmark$%
endocg%
%
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

usepackagetikz
usetikzlibrarypositioning,fit,calc
pgfdeclarelayerbehind
pgfdeclarelayerbackground
pgfdeclarelayerforeground
pgfsetlayersbehind,background,main,foreground
tikzset
text field/.style=text height=1.5ex,align=center,rounded corners,
nonfillable title field/.style=text height=2ex,text depth=0.3em,anchor=south,text
width=5cm,align=center,font=footnotesizesffamily,
pics/nonfillable subject/.style=code= (-TF.south east)
-- cycle;
draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
,
manoooh/.style=column sep=-1.75cm,row sep=5mm,
fit sep/.initial=4pt, % change width of node (big rectangle shape)
fit dist/.initial=40pt, % change node distance (big rectangle shape)
inlay top sep/.initial=24pt,
matrix top sep/.initial=24pt,
manoooh curve/.style=to path=let p1=($(tikztotarget)-(tikztostart)$)
in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget),
manoooh curve/.default=0.3,
along node/.style=insert path=
to[out=0,in=180]
([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)
% From https://tex.stackexchange.com/a/478723/152550

makeatletter% from https://tex.stackexchange.com/a/85531/121799
longdefifnodedefined#1#2#3%
@ifundefinedpgf@sh@ns@#1#3#2%

makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%
newcommandtotalnodes1 % Define the total of subjects that need arrows-1
%%%%%%%%%%%%%%%%%%%%%%%%%

begindocument

ifdefinedmymatbottom
else
typeoutPleasespace recompilespace yourspace file!
defmymatbottom-150pt
fi
ifdefinedmyheight
else
defmyheight0
typeoutPleasespace recompilespace yourspace file!
fi
ifdefinedLstMatYShifts
else
defLstMatYShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
fi
ifdefinedLstMatXShifts
else
defLstMatXShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
fi

begintikzpicture
% step 1: add the matrices, name them mat0, mat1 etc.
beginscope[local bounding box=matrices]
matrix[manoooh] (mat0) at (LstMatXShifts[0],LstMatYShifts[0])
pic[local bounding box=A] (0) nonfillable subject=Subject0; & &
pic (1) nonfillable subject=Subject1; \
& pic (2) nonfillable subject=Subject2; & \
;
matrix[manoooh] (mat1) at (LstMatXShifts[1],LstMatYShifts[1])
pic (3) nonfillable subject=Subject3; \
pic (4) nonfillable subject=Subject4; \
pic (5) nonfillable subject=Subject5; \
pic (6) nonfillable subject=Subject6; \
pic (7) nonfillable subject=Subject7; \
pic (8) nonfillable subject=Subject8; \
;
endscope
pgfmathsetmacrogroupwidth0
pgfmathsetmacrolastwidth0
foreach X in 0,...,1 %<- if you have more or less matrices, adjust 3
ifnodedefinedmatEX

% has inlay


% no inlay
path
let p1=($(matX.north east)-(matX.south west)$),
n1=max(abs(y1)/2,mymatbottom)
in
pgfextraxdefmymatbottomn1
ifnumX=0
pgfmathsetmacrogroupwidth0
else
pgfmathsetmacrogroupwidthgroupwidth+x1/2+lastwidth/2+pgfkeysvalueof/tikz/fit dist
fi
xdefgroupwidthgroupwidth
xdeflastwidthx1
pgfmathsetmacromyheightmax(y1+pgfkeysvalueof/tikz/matrix top sep,myheight)
xdefmyheightmyheight
ifnumX=0
xdefLstMatYShifts0pt
xdefLstMatXShifts0pt
else
xdefLstMatYShiftsLstMatYShifts,0pt
xdefLstMatXShiftsLstMatXShifts,groupwidth pt
fi;
% the fit parameters determine the shape of the background rectangles


makeatletter
immediatewrite@mainauxxdefstringmymatbottom-mymatbottomrelax
immediatewrite@mainauxxdefstringmyheightmyheightrelax
immediatewrite@mainauxxdefstringLstMatYShiftsLstMatYShiftsrelax
immediatewrite@mainauxxdefstringLstMatXShiftsLstMatXShiftsrelax
makeatother

% From https://tex.stackexchange.com/a/480685/152550

% now add the arrows.

gdefLstCon%

"6/1",
"4",


pgfmathsetmacromylstLstCon[0]
foreach X in 0,...,totalnodes
beginscope[ocg=name=ArrowX,ref=myArrowX,status=visible]
pgfmathsetmacrohuenumX*0.75*(1/totalnodes)
definecolormycolorhsbhuenum,1,1
pgfmathsetmacromylstLstCon[X]
%typeoutX:mylst
foreach Y/myalong in mylst
ifxmyalongY
%typeoutX:Y,empty
draw[-latex,mycolor,very thick] (X-Title.east)
to[manoooh curve] (Y-Title.west);
else
%typeoutX:Yspace andspace myalong
draw[-latex,mycolor,very thick] (X-Title.east)
[along node/.list/.expanded=myalong]
to[manoooh curve] (Y-Title.west);
fi

endscope

%pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
%definecolormycolor2hsbhuenumm,1,1
%draw[-latex,mycolor2,very thick] (2-Title.east) -- ++ (3,0) to[manoooh curve=1.6] (3-Title.west);
endtikzpicture

flushleft
qquadparbox0.4linewidth%
hypersetuppdfborder=0 0 0%
% list of OCGs, space separated
defocglist%
foreach X in 0,...,totalnodes xdefocglistocglistspace myArrowX
fbox%
parbox12cm%
% on/off All
showocgocglistfboxsep=1ptfboxrule0pt1.7exon/%
hideocgocglistfboxsep=1ptfboxrule0pt1.7exoff All\%
% checkboxes
foreach X in 0,...,totalnodes %
layerCheckBoxmyArrowXonbegintikzpicture[baseline=-1ex]%
pgfmathsetmacrohuenumX*0.75*(1/totalnodes)%
definecolormycolorhsbhuenum,1,1draw[-latex,mycolor,very thick] (0,0) -- (1,0);%
endtikzpictureqquad%
%




enddocument


MWE output



It works fantastic.



Now I want to add another arrow, that goes from (2) to (3), so one would probably add



"3",


to the LstCon object (please increment the value of totalnodes by 1!), but this produces an ugly output, because it collides with "Subject1".



To fix this, I have been told that I need to create this new arrow outside the foreach loop that it is inside the tikzpicture environment. So I have deleted "3", and added the following three lines to the code:



pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
definecolormycolor2hsbhuenumm,1,1
draw[-latex,mycolor2,very thick] -- ++ (3,0) (2-Title.east) to[manoooh curve=1.6] (3-Title.west);


You only need to uncomment that lines of the given MWE to get this output:



New output



It looks like there are no problems.



However, adding that arrow outside the foreach loop makes the checkbox of it non-clickable:



The problem



I want to make it possible to click on this new checkbox. How can we do it?



Thanks!!



P.S. Also I am getting an overfull hbox bad box message because of the parbox. Could you consider try to find out why I am getting it?









share


























    0















    This is an addendum of a previous question: How to put a box and use columns to separate arrows.



    Please consider this MWE (adapted from a nice answer of that question):



    documentclassarticle
    usepackage[margin=0in,footskip=0in]geometry
    usepackage[english]babel
    usepackage[utf8]inputenc
    usepackage[T1]fontenc
    usepackagehyperref
    usepackage[tikz]ocgx2
    usepackageamssymb % checkmark
    % check box command for layer switching
    newcommandlayerCheckBox[3]%
    % #1: switch id, if empty use #2 instead
    % #2: layer ids to be toggled (space separated if multiple ids),
    % #3: initial visibility
    resizebox2ex!%
    ooalign%
    switchocg#1 #2$square$cr%
    beginocg%
    ifxnil#1nil#2else#1fi%
    %
    %
    ifxnil#1nil#2else#1fi%
    #3$checkmark$%
    endocg%
    %
    %

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    usepackagetikz
    usetikzlibrarypositioning,fit,calc
    pgfdeclarelayerbehind
    pgfdeclarelayerbackground
    pgfdeclarelayerforeground
    pgfsetlayersbehind,background,main,foreground
    tikzset
    text field/.style=text height=1.5ex,align=center,rounded corners,
    nonfillable title field/.style=text height=2ex,text depth=0.3em,anchor=south,text
    width=5cm,align=center,font=footnotesizesffamily,
    pics/nonfillable subject/.style=code= (-TF.south east)
    -- cycle;
    draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
    ,
    manoooh/.style=column sep=-1.75cm,row sep=5mm,
    fit sep/.initial=4pt, % change width of node (big rectangle shape)
    fit dist/.initial=40pt, % change node distance (big rectangle shape)
    inlay top sep/.initial=24pt,
    matrix top sep/.initial=24pt,
    manoooh curve/.style=to path=let p1=($(tikztotarget)-(tikztostart)$)
    in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
    and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget),
    manoooh curve/.default=0.3,
    along node/.style=insert path=
    to[out=0,in=180]
    ([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)
    % From https://tex.stackexchange.com/a/478723/152550

    makeatletter% from https://tex.stackexchange.com/a/85531/121799
    longdefifnodedefined#1#2#3%
    @ifundefinedpgf@sh@ns@#1#3#2%

    makeatother

    %%%%%%%%%%%%%%%%%%%%%%%%%
    newcommandtotalnodes1 % Define the total of subjects that need arrows-1
    %%%%%%%%%%%%%%%%%%%%%%%%%

    begindocument

    ifdefinedmymatbottom
    else
    typeoutPleasespace recompilespace yourspace file!
    defmymatbottom-150pt
    fi
    ifdefinedmyheight
    else
    defmyheight0
    typeoutPleasespace recompilespace yourspace file!
    fi
    ifdefinedLstMatYShifts
    else
    defLstMatYShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
    fi
    ifdefinedLstMatXShifts
    else
    defLstMatXShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
    fi

    begintikzpicture
    % step 1: add the matrices, name them mat0, mat1 etc.
    beginscope[local bounding box=matrices]
    matrix[manoooh] (mat0) at (LstMatXShifts[0],LstMatYShifts[0])
    pic[local bounding box=A] (0) nonfillable subject=Subject0; & &
    pic (1) nonfillable subject=Subject1; \
    & pic (2) nonfillable subject=Subject2; & \
    ;
    matrix[manoooh] (mat1) at (LstMatXShifts[1],LstMatYShifts[1])
    pic (3) nonfillable subject=Subject3; \
    pic (4) nonfillable subject=Subject4; \
    pic (5) nonfillable subject=Subject5; \
    pic (6) nonfillable subject=Subject6; \
    pic (7) nonfillable subject=Subject7; \
    pic (8) nonfillable subject=Subject8; \
    ;
    endscope
    pgfmathsetmacrogroupwidth0
    pgfmathsetmacrolastwidth0
    foreach X in 0,...,1 %<- if you have more or less matrices, adjust 3
    ifnodedefinedmatEX

    % has inlay


    % no inlay
    path
    let p1=($(matX.north east)-(matX.south west)$),
    n1=max(abs(y1)/2,mymatbottom)
    in
    pgfextraxdefmymatbottomn1
    ifnumX=0
    pgfmathsetmacrogroupwidth0
    else
    pgfmathsetmacrogroupwidthgroupwidth+x1/2+lastwidth/2+pgfkeysvalueof/tikz/fit dist
    fi
    xdefgroupwidthgroupwidth
    xdeflastwidthx1
    pgfmathsetmacromyheightmax(y1+pgfkeysvalueof/tikz/matrix top sep,myheight)
    xdefmyheightmyheight
    ifnumX=0
    xdefLstMatYShifts0pt
    xdefLstMatXShifts0pt
    else
    xdefLstMatYShiftsLstMatYShifts,0pt
    xdefLstMatXShiftsLstMatXShifts,groupwidth pt
    fi;
    % the fit parameters determine the shape of the background rectangles


    makeatletter
    immediatewrite@mainauxxdefstringmymatbottom-mymatbottomrelax
    immediatewrite@mainauxxdefstringmyheightmyheightrelax
    immediatewrite@mainauxxdefstringLstMatYShiftsLstMatYShiftsrelax
    immediatewrite@mainauxxdefstringLstMatXShiftsLstMatXShiftsrelax
    makeatother

    % From https://tex.stackexchange.com/a/480685/152550

    % now add the arrows.

    gdefLstCon%

    "6/1",
    "4",


    pgfmathsetmacromylstLstCon[0]
    foreach X in 0,...,totalnodes
    beginscope[ocg=name=ArrowX,ref=myArrowX,status=visible]
    pgfmathsetmacrohuenumX*0.75*(1/totalnodes)
    definecolormycolorhsbhuenum,1,1
    pgfmathsetmacromylstLstCon[X]
    %typeoutX:mylst
    foreach Y/myalong in mylst
    ifxmyalongY
    %typeoutX:Y,empty
    draw[-latex,mycolor,very thick] (X-Title.east)
    to[manoooh curve] (Y-Title.west);
    else
    %typeoutX:Yspace andspace myalong
    draw[-latex,mycolor,very thick] (X-Title.east)
    [along node/.list/.expanded=myalong]
    to[manoooh curve] (Y-Title.west);
    fi

    endscope

    %pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
    %definecolormycolor2hsbhuenumm,1,1
    %draw[-latex,mycolor2,very thick] (2-Title.east) -- ++ (3,0) to[manoooh curve=1.6] (3-Title.west);
    endtikzpicture

    flushleft
    qquadparbox0.4linewidth%
    hypersetuppdfborder=0 0 0%
    % list of OCGs, space separated
    defocglist%
    foreach X in 0,...,totalnodes xdefocglistocglistspace myArrowX
    fbox%
    parbox12cm%
    % on/off All
    showocgocglistfboxsep=1ptfboxrule0pt1.7exon/%
    hideocgocglistfboxsep=1ptfboxrule0pt1.7exoff All\%
    % checkboxes
    foreach X in 0,...,totalnodes %
    layerCheckBoxmyArrowXonbegintikzpicture[baseline=-1ex]%
    pgfmathsetmacrohuenumX*0.75*(1/totalnodes)%
    definecolormycolorhsbhuenum,1,1draw[-latex,mycolor,very thick] (0,0) -- (1,0);%
    endtikzpictureqquad%
    %




    enddocument


    MWE output



    It works fantastic.



    Now I want to add another arrow, that goes from (2) to (3), so one would probably add



    "3",


    to the LstCon object (please increment the value of totalnodes by 1!), but this produces an ugly output, because it collides with "Subject1".



    To fix this, I have been told that I need to create this new arrow outside the foreach loop that it is inside the tikzpicture environment. So I have deleted "3", and added the following three lines to the code:



    pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
    definecolormycolor2hsbhuenumm,1,1
    draw[-latex,mycolor2,very thick] -- ++ (3,0) (2-Title.east) to[manoooh curve=1.6] (3-Title.west);


    You only need to uncomment that lines of the given MWE to get this output:



    New output



    It looks like there are no problems.



    However, adding that arrow outside the foreach loop makes the checkbox of it non-clickable:



    The problem



    I want to make it possible to click on this new checkbox. How can we do it?



    Thanks!!



    P.S. Also I am getting an overfull hbox bad box message because of the parbox. Could you consider try to find out why I am getting it?









    share
























      0












      0








      0








      This is an addendum of a previous question: How to put a box and use columns to separate arrows.



      Please consider this MWE (adapted from a nice answer of that question):



      documentclassarticle
      usepackage[margin=0in,footskip=0in]geometry
      usepackage[english]babel
      usepackage[utf8]inputenc
      usepackage[T1]fontenc
      usepackagehyperref
      usepackage[tikz]ocgx2
      usepackageamssymb % checkmark
      % check box command for layer switching
      newcommandlayerCheckBox[3]%
      % #1: switch id, if empty use #2 instead
      % #2: layer ids to be toggled (space separated if multiple ids),
      % #3: initial visibility
      resizebox2ex!%
      ooalign%
      switchocg#1 #2$square$cr%
      beginocg%
      ifxnil#1nil#2else#1fi%
      %
      %
      ifxnil#1nil#2else#1fi%
      #3$checkmark$%
      endocg%
      %
      %

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      usepackagetikz
      usetikzlibrarypositioning,fit,calc
      pgfdeclarelayerbehind
      pgfdeclarelayerbackground
      pgfdeclarelayerforeground
      pgfsetlayersbehind,background,main,foreground
      tikzset
      text field/.style=text height=1.5ex,align=center,rounded corners,
      nonfillable title field/.style=text height=2ex,text depth=0.3em,anchor=south,text
      width=5cm,align=center,font=footnotesizesffamily,
      pics/nonfillable subject/.style=code= (-TF.south east)
      -- cycle;
      draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
      ,
      manoooh/.style=column sep=-1.75cm,row sep=5mm,
      fit sep/.initial=4pt, % change width of node (big rectangle shape)
      fit dist/.initial=40pt, % change node distance (big rectangle shape)
      inlay top sep/.initial=24pt,
      matrix top sep/.initial=24pt,
      manoooh curve/.style=to path=let p1=($(tikztotarget)-(tikztostart)$)
      in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
      and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget),
      manoooh curve/.default=0.3,
      along node/.style=insert path=
      to[out=0,in=180]
      ([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)
      % From https://tex.stackexchange.com/a/478723/152550

      makeatletter% from https://tex.stackexchange.com/a/85531/121799
      longdefifnodedefined#1#2#3%
      @ifundefinedpgf@sh@ns@#1#3#2%

      makeatother

      %%%%%%%%%%%%%%%%%%%%%%%%%
      newcommandtotalnodes1 % Define the total of subjects that need arrows-1
      %%%%%%%%%%%%%%%%%%%%%%%%%

      begindocument

      ifdefinedmymatbottom
      else
      typeoutPleasespace recompilespace yourspace file!
      defmymatbottom-150pt
      fi
      ifdefinedmyheight
      else
      defmyheight0
      typeoutPleasespace recompilespace yourspace file!
      fi
      ifdefinedLstMatYShifts
      else
      defLstMatYShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
      fi
      ifdefinedLstMatXShifts
      else
      defLstMatXShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
      fi

      begintikzpicture
      % step 1: add the matrices, name them mat0, mat1 etc.
      beginscope[local bounding box=matrices]
      matrix[manoooh] (mat0) at (LstMatXShifts[0],LstMatYShifts[0])
      pic[local bounding box=A] (0) nonfillable subject=Subject0; & &
      pic (1) nonfillable subject=Subject1; \
      & pic (2) nonfillable subject=Subject2; & \
      ;
      matrix[manoooh] (mat1) at (LstMatXShifts[1],LstMatYShifts[1])
      pic (3) nonfillable subject=Subject3; \
      pic (4) nonfillable subject=Subject4; \
      pic (5) nonfillable subject=Subject5; \
      pic (6) nonfillable subject=Subject6; \
      pic (7) nonfillable subject=Subject7; \
      pic (8) nonfillable subject=Subject8; \
      ;
      endscope
      pgfmathsetmacrogroupwidth0
      pgfmathsetmacrolastwidth0
      foreach X in 0,...,1 %<- if you have more or less matrices, adjust 3
      ifnodedefinedmatEX

      % has inlay


      % no inlay
      path
      let p1=($(matX.north east)-(matX.south west)$),
      n1=max(abs(y1)/2,mymatbottom)
      in
      pgfextraxdefmymatbottomn1
      ifnumX=0
      pgfmathsetmacrogroupwidth0
      else
      pgfmathsetmacrogroupwidthgroupwidth+x1/2+lastwidth/2+pgfkeysvalueof/tikz/fit dist
      fi
      xdefgroupwidthgroupwidth
      xdeflastwidthx1
      pgfmathsetmacromyheightmax(y1+pgfkeysvalueof/tikz/matrix top sep,myheight)
      xdefmyheightmyheight
      ifnumX=0
      xdefLstMatYShifts0pt
      xdefLstMatXShifts0pt
      else
      xdefLstMatYShiftsLstMatYShifts,0pt
      xdefLstMatXShiftsLstMatXShifts,groupwidth pt
      fi;
      % the fit parameters determine the shape of the background rectangles


      makeatletter
      immediatewrite@mainauxxdefstringmymatbottom-mymatbottomrelax
      immediatewrite@mainauxxdefstringmyheightmyheightrelax
      immediatewrite@mainauxxdefstringLstMatYShiftsLstMatYShiftsrelax
      immediatewrite@mainauxxdefstringLstMatXShiftsLstMatXShiftsrelax
      makeatother

      % From https://tex.stackexchange.com/a/480685/152550

      % now add the arrows.

      gdefLstCon%

      "6/1",
      "4",


      pgfmathsetmacromylstLstCon[0]
      foreach X in 0,...,totalnodes
      beginscope[ocg=name=ArrowX,ref=myArrowX,status=visible]
      pgfmathsetmacrohuenumX*0.75*(1/totalnodes)
      definecolormycolorhsbhuenum,1,1
      pgfmathsetmacromylstLstCon[X]
      %typeoutX:mylst
      foreach Y/myalong in mylst
      ifxmyalongY
      %typeoutX:Y,empty
      draw[-latex,mycolor,very thick] (X-Title.east)
      to[manoooh curve] (Y-Title.west);
      else
      %typeoutX:Yspace andspace myalong
      draw[-latex,mycolor,very thick] (X-Title.east)
      [along node/.list/.expanded=myalong]
      to[manoooh curve] (Y-Title.west);
      fi

      endscope

      %pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
      %definecolormycolor2hsbhuenumm,1,1
      %draw[-latex,mycolor2,very thick] (2-Title.east) -- ++ (3,0) to[manoooh curve=1.6] (3-Title.west);
      endtikzpicture

      flushleft
      qquadparbox0.4linewidth%
      hypersetuppdfborder=0 0 0%
      % list of OCGs, space separated
      defocglist%
      foreach X in 0,...,totalnodes xdefocglistocglistspace myArrowX
      fbox%
      parbox12cm%
      % on/off All
      showocgocglistfboxsep=1ptfboxrule0pt1.7exon/%
      hideocgocglistfboxsep=1ptfboxrule0pt1.7exoff All\%
      % checkboxes
      foreach X in 0,...,totalnodes %
      layerCheckBoxmyArrowXonbegintikzpicture[baseline=-1ex]%
      pgfmathsetmacrohuenumX*0.75*(1/totalnodes)%
      definecolormycolorhsbhuenum,1,1draw[-latex,mycolor,very thick] (0,0) -- (1,0);%
      endtikzpictureqquad%
      %




      enddocument


      MWE output



      It works fantastic.



      Now I want to add another arrow, that goes from (2) to (3), so one would probably add



      "3",


      to the LstCon object (please increment the value of totalnodes by 1!), but this produces an ugly output, because it collides with "Subject1".



      To fix this, I have been told that I need to create this new arrow outside the foreach loop that it is inside the tikzpicture environment. So I have deleted "3", and added the following three lines to the code:



      pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
      definecolormycolor2hsbhuenumm,1,1
      draw[-latex,mycolor2,very thick] -- ++ (3,0) (2-Title.east) to[manoooh curve=1.6] (3-Title.west);


      You only need to uncomment that lines of the given MWE to get this output:



      New output



      It looks like there are no problems.



      However, adding that arrow outside the foreach loop makes the checkbox of it non-clickable:



      The problem



      I want to make it possible to click on this new checkbox. How can we do it?



      Thanks!!



      P.S. Also I am getting an overfull hbox bad box message because of the parbox. Could you consider try to find out why I am getting it?









      share














      This is an addendum of a previous question: How to put a box and use columns to separate arrows.



      Please consider this MWE (adapted from a nice answer of that question):



      documentclassarticle
      usepackage[margin=0in,footskip=0in]geometry
      usepackage[english]babel
      usepackage[utf8]inputenc
      usepackage[T1]fontenc
      usepackagehyperref
      usepackage[tikz]ocgx2
      usepackageamssymb % checkmark
      % check box command for layer switching
      newcommandlayerCheckBox[3]%
      % #1: switch id, if empty use #2 instead
      % #2: layer ids to be toggled (space separated if multiple ids),
      % #3: initial visibility
      resizebox2ex!%
      ooalign%
      switchocg#1 #2$square$cr%
      beginocg%
      ifxnil#1nil#2else#1fi%
      %
      %
      ifxnil#1nil#2else#1fi%
      #3$checkmark$%
      endocg%
      %
      %

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      usepackagetikz
      usetikzlibrarypositioning,fit,calc
      pgfdeclarelayerbehind
      pgfdeclarelayerbackground
      pgfdeclarelayerforeground
      pgfsetlayersbehind,background,main,foreground
      tikzset
      text field/.style=text height=1.5ex,align=center,rounded corners,
      nonfillable title field/.style=text height=2ex,text depth=0.3em,anchor=south,text
      width=5cm,align=center,font=footnotesizesffamily,
      pics/nonfillable subject/.style=code= (-TF.south east)
      -- cycle;
      draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
      ,
      manoooh/.style=column sep=-1.75cm,row sep=5mm,
      fit sep/.initial=4pt, % change width of node (big rectangle shape)
      fit dist/.initial=40pt, % change node distance (big rectangle shape)
      inlay top sep/.initial=24pt,
      matrix top sep/.initial=24pt,
      manoooh curve/.style=to path=let p1=($(tikztotarget)-(tikztostart)$)
      in (tikztostart) .. controls ($(tikztostart)+(#1*x1,0)$)
      and ($(tikztotarget)+(-#1*x1,0)$) .. (tikztotarget),
      manoooh curve/.default=0.3,
      along node/.style=insert path=
      to[out=0,in=180]
      ([yshift=5pt]#1-Title.north west) -- ([yshift=5pt]#1-Title.north east)
      % From https://tex.stackexchange.com/a/478723/152550

      makeatletter% from https://tex.stackexchange.com/a/85531/121799
      longdefifnodedefined#1#2#3%
      @ifundefinedpgf@sh@ns@#1#3#2%

      makeatother

      %%%%%%%%%%%%%%%%%%%%%%%%%
      newcommandtotalnodes1 % Define the total of subjects that need arrows-1
      %%%%%%%%%%%%%%%%%%%%%%%%%

      begindocument

      ifdefinedmymatbottom
      else
      typeoutPleasespace recompilespace yourspace file!
      defmymatbottom-150pt
      fi
      ifdefinedmyheight
      else
      defmyheight0
      typeoutPleasespace recompilespace yourspace file!
      fi
      ifdefinedLstMatYShifts
      else
      defLstMatYShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
      fi
      ifdefinedLstMatXShifts
      else
      defLstMatXShifts0pt,0pt,0pt,0pt,0pt,0pt,0pt
      fi

      begintikzpicture
      % step 1: add the matrices, name them mat0, mat1 etc.
      beginscope[local bounding box=matrices]
      matrix[manoooh] (mat0) at (LstMatXShifts[0],LstMatYShifts[0])
      pic[local bounding box=A] (0) nonfillable subject=Subject0; & &
      pic (1) nonfillable subject=Subject1; \
      & pic (2) nonfillable subject=Subject2; & \
      ;
      matrix[manoooh] (mat1) at (LstMatXShifts[1],LstMatYShifts[1])
      pic (3) nonfillable subject=Subject3; \
      pic (4) nonfillable subject=Subject4; \
      pic (5) nonfillable subject=Subject5; \
      pic (6) nonfillable subject=Subject6; \
      pic (7) nonfillable subject=Subject7; \
      pic (8) nonfillable subject=Subject8; \
      ;
      endscope
      pgfmathsetmacrogroupwidth0
      pgfmathsetmacrolastwidth0
      foreach X in 0,...,1 %<- if you have more or less matrices, adjust 3
      ifnodedefinedmatEX

      % has inlay


      % no inlay
      path
      let p1=($(matX.north east)-(matX.south west)$),
      n1=max(abs(y1)/2,mymatbottom)
      in
      pgfextraxdefmymatbottomn1
      ifnumX=0
      pgfmathsetmacrogroupwidth0
      else
      pgfmathsetmacrogroupwidthgroupwidth+x1/2+lastwidth/2+pgfkeysvalueof/tikz/fit dist
      fi
      xdefgroupwidthgroupwidth
      xdeflastwidthx1
      pgfmathsetmacromyheightmax(y1+pgfkeysvalueof/tikz/matrix top sep,myheight)
      xdefmyheightmyheight
      ifnumX=0
      xdefLstMatYShifts0pt
      xdefLstMatXShifts0pt
      else
      xdefLstMatYShiftsLstMatYShifts,0pt
      xdefLstMatXShiftsLstMatXShifts,groupwidth pt
      fi;
      % the fit parameters determine the shape of the background rectangles


      makeatletter
      immediatewrite@mainauxxdefstringmymatbottom-mymatbottomrelax
      immediatewrite@mainauxxdefstringmyheightmyheightrelax
      immediatewrite@mainauxxdefstringLstMatYShiftsLstMatYShiftsrelax
      immediatewrite@mainauxxdefstringLstMatXShiftsLstMatXShiftsrelax
      makeatother

      % From https://tex.stackexchange.com/a/480685/152550

      % now add the arrows.

      gdefLstCon%

      "6/1",
      "4",


      pgfmathsetmacromylstLstCon[0]
      foreach X in 0,...,totalnodes
      beginscope[ocg=name=ArrowX,ref=myArrowX,status=visible]
      pgfmathsetmacrohuenumX*0.75*(1/totalnodes)
      definecolormycolorhsbhuenum,1,1
      pgfmathsetmacromylstLstCon[X]
      %typeoutX:mylst
      foreach Y/myalong in mylst
      ifxmyalongY
      %typeoutX:Y,empty
      draw[-latex,mycolor,very thick] (X-Title.east)
      to[manoooh curve] (Y-Title.west);
      else
      %typeoutX:Yspace andspace myalong
      draw[-latex,mycolor,very thick] (X-Title.east)
      [along node/.list/.expanded=myalong]
      to[manoooh curve] (Y-Title.west);
      fi

      endscope

      %pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
      %definecolormycolor2hsbhuenumm,1,1
      %draw[-latex,mycolor2,very thick] (2-Title.east) -- ++ (3,0) to[manoooh curve=1.6] (3-Title.west);
      endtikzpicture

      flushleft
      qquadparbox0.4linewidth%
      hypersetuppdfborder=0 0 0%
      % list of OCGs, space separated
      defocglist%
      foreach X in 0,...,totalnodes xdefocglistocglistspace myArrowX
      fbox%
      parbox12cm%
      % on/off All
      showocgocglistfboxsep=1ptfboxrule0pt1.7exon/%
      hideocgocglistfboxsep=1ptfboxrule0pt1.7exoff All\%
      % checkboxes
      foreach X in 0,...,totalnodes %
      layerCheckBoxmyArrowXonbegintikzpicture[baseline=-1ex]%
      pgfmathsetmacrohuenumX*0.75*(1/totalnodes)%
      definecolormycolorhsbhuenum,1,1draw[-latex,mycolor,very thick] (0,0) -- (1,0);%
      endtikzpictureqquad%
      %




      enddocument


      MWE output



      It works fantastic.



      Now I want to add another arrow, that goes from (2) to (3), so one would probably add



      "3",


      to the LstCon object (please increment the value of totalnodes by 1!), but this produces an ugly output, because it collides with "Subject1".



      To fix this, I have been told that I need to create this new arrow outside the foreach loop that it is inside the tikzpicture environment. So I have deleted "3", and added the following three lines to the code:



      pgfmathsetmacrohuenumm2*0.75*(1/totalnodes)
      definecolormycolor2hsbhuenumm,1,1
      draw[-latex,mycolor2,very thick] -- ++ (3,0) (2-Title.east) to[manoooh curve=1.6] (3-Title.west);


      You only need to uncomment that lines of the given MWE to get this output:



      New output



      It looks like there are no problems.



      However, adding that arrow outside the foreach loop makes the checkbox of it non-clickable:



      The problem



      I want to make it possible to click on this new checkbox. How can we do it?



      Thanks!!



      P.S. Also I am getting an overfull hbox bad box message because of the parbox. Could you consider try to find out why I am getting it?







      tikz-pgf ocgx2





      share












      share










      share



      share










      asked 5 mins ago









      manoooohmanooooh

      1,1681517




      1,1681517




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482674%2fhow-to-add-a-particular-object-to-an-ocg-list%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482674%2fhow-to-add-a-particular-object-to-an-ocg-list%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How should I use the fbox command correctly to avoid producing a Bad Box message?How to put a long piece of text in a box?How to specify height and width of fboxIs there an arrayrulecolor-like command to change the rule color of fbox?What is the command to highlight bad boxes in pdf?Why does fbox sometimes place the box *over* the graphic image?how to put the text in the boxHow to create command for a box where text inside the box can automatically adjust?how can I make an fbox like command with certain color, shape and width of border?how to use fbox in align modeFbox increase the spacing between the box and it content (inner margin)how to change the box height of an equationWhat is the use of the hbox in a newcommand command?

          Doxepinum Nexus interni Notae | Tabula navigationis3158DB01142WHOa682390"Structural Analysis of the Histamine H1 Receptor""Transdermal and Topical Drug Administration in the Treatment of Pain""Antidepressants as antipruritic agents: A review"

          inputenc: Unicode character … not set up for use with LaTeX The Next CEO of Stack OverflowEntering Unicode characters in LaTeXHow to solve the `Package inputenc Error: Unicode char not set up for use with LaTeX` problem?solve “Unicode char is not set up for use with LaTeX” without special handling of every new interesting UTF-8 characterPackage inputenc Error: Unicode character ² (U+B2)(inputenc) not set up for use with LaTeX. acroI2C[I²C]package inputenc error unicode char (u + 190) not set up for use with latexPackage inputenc Error: Unicode char u8:′ not set up for use with LaTeX. 3′inputenc Error: Unicode char u8: not set up for use with LaTeX with G-BriefPackage Inputenc Error: Unicode char u8: not set up for use with LaTeXPackage inputenc Error: Unicode char ́ (U+301)(inputenc) not set up for use with LaTeX. includePackage inputenc Error: Unicode char ̂ (U+302)(inputenc) not set up for use with LaTeX. … $widehatleft (OA,AA' right )$Package inputenc Error: Unicode char â„¡ (U+2121)(inputenc) not set up for use with LaTeX. printbibliography[heading=bibintoc]Package inputenc Error: Unicode char − (U+2212)(inputenc) not set up for use with LaTeXPackage inputenc Error: Unicode character α (U+3B1) not set up for use with LaTeXPackage inputenc Error: Unicode characterError: ! Package inputenc Error: Unicode char ⊘ (U+2298)(inputenc) not set up for use with LaTeX