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?
Upgrading From a 9 Speed Sora Derailleur?
Is the offspring between a demon and a celestial possible? If so what is it called and is it in a book somewhere?
Gauss' Posthumous Publications?
Does Germany produce more waste than the US?
Why was Sir Cadogan fired?
What steps are necessary to read a Modern SSD in Medieval Europe?
What is the difference between 'contrib' and 'non-free' packages repositories?
Free fall ellipse or parabola?
My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?
How exploitable/balanced is this homebrew spell: Spell Permanency?
How can a day be of 24 hours?
Could a dragon use its wings to swim?
My boss doesn't want me to have a side project
Is a distribution that is normal, but highly skewed, considered Gaussian?
How to pronounce fünf in 45
Salesforce opportunity stages
Which acid/base does a strong base/acid react when added to a buffer solution?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Simplify trigonometric expression using trigonometric identities
Is it okay to majorly distort historical facts while writing a fiction story?
Prodigo = pro + ago?
How should I connect my cat5 cable to connectors having an orange-green line?
Direct Implications Between USA and UK in Event of No-Deal Brexit
Can you teleport closer to a creature you are Frightened of?
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?
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=- (-Title.south west)
,
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
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:
It looks like there are no problems.
However, adding that arrow outside the foreach
loop makes the checkbox of it non-clickable:
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
add a comment |
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=- (-Title.south west)
,
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
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:
It looks like there are no problems.
However, adding that arrow outside the foreach
loop makes the checkbox of it non-clickable:
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
add a comment |
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=- (-Title.south west)
,
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
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:
It looks like there are no problems.
However, adding that arrow outside the foreach
loop makes the checkbox of it non-clickable:
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
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=- (-Title.south west)
,
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
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:
It looks like there are no problems.
However, adding that arrow outside the foreach
loop makes the checkbox of it non-clickable:
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
tikz-pgf ocgx2
asked 6 mins ago
manoooohmanooooh
1,1731517
1,1731517
add a comment |
add a comment |
0
active
oldest
votes
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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