Conditionally include a line based on an option with pgfpackages












0















I am trying to design a small package, mostly for test purpose. Currently the package looks like this:



% eqbox.sty
NeedsTeXFormat{LaTeX2e}[1994/06/01]
ProvidesPackage{eqbox}[2019/01/01 Boxed Equations]

RequirePackage{xcolor}
RequirePackage{pgfopts}
RequirePackage{amsmath}
RequirePackage{fancybox}
RequirePackage[most]{tcolorbox}

pgfkeys{
/eqbox/.cd,
colframe/.store in = colframe,
colframe = black,
colback/.store in = colback,
colback = white,
shadow/.store in = shadow,
shadow = undefined,
}
ProcessPgfPackageOptions{/eqbox}

tcbset{
highlight math style={
enhanced,
sharp corners,
breakable,
colframe=colframe,
colback=colback,
ifxundefinedshadow
else
shadow={2pt}{-2pt}{0mm}{shadow},
fi
boxrule=0.4pt,
boxsep = 3pt,
left = 0pt,
right = 0pt,
top = 0pt,
bottom = 0pt
}
}


and I can try to use it this way:



documentclass[letterpaper, 11pt, onecolumn]{article}

usepackage{lipsum}
usepackage{eqbox}

begin{document}
lipsum[1]
begin{equation}
tcbhighmath{x^2 + 3}
end{equation}
lipsum[1]
end{document}


However it does not work. My intent is that:




  • By default, usepackage{eqbox} does not provide any shadow

  • If the user writes usepackage[shadow=blue]{eqbox} then equations are put in boxes with a blue shadow


How to make that work? (I think I do not know how to use ifx to make that work)



EDIT: I also tried:



ifdefinedshadow
shadow={2pt}{-2pt}{0mm}{shadow},
fi


but it does not work either










share|improve this question

























  • One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

    – marmot
    3 hours ago











  • You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

    – Kpym
    3 hours ago













  • @Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

    – Vincent
    3 hours ago













  • I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

    – Kpym
    3 hours ago
















0















I am trying to design a small package, mostly for test purpose. Currently the package looks like this:



% eqbox.sty
NeedsTeXFormat{LaTeX2e}[1994/06/01]
ProvidesPackage{eqbox}[2019/01/01 Boxed Equations]

RequirePackage{xcolor}
RequirePackage{pgfopts}
RequirePackage{amsmath}
RequirePackage{fancybox}
RequirePackage[most]{tcolorbox}

pgfkeys{
/eqbox/.cd,
colframe/.store in = colframe,
colframe = black,
colback/.store in = colback,
colback = white,
shadow/.store in = shadow,
shadow = undefined,
}
ProcessPgfPackageOptions{/eqbox}

tcbset{
highlight math style={
enhanced,
sharp corners,
breakable,
colframe=colframe,
colback=colback,
ifxundefinedshadow
else
shadow={2pt}{-2pt}{0mm}{shadow},
fi
boxrule=0.4pt,
boxsep = 3pt,
left = 0pt,
right = 0pt,
top = 0pt,
bottom = 0pt
}
}


and I can try to use it this way:



documentclass[letterpaper, 11pt, onecolumn]{article}

usepackage{lipsum}
usepackage{eqbox}

begin{document}
lipsum[1]
begin{equation}
tcbhighmath{x^2 + 3}
end{equation}
lipsum[1]
end{document}


However it does not work. My intent is that:




  • By default, usepackage{eqbox} does not provide any shadow

  • If the user writes usepackage[shadow=blue]{eqbox} then equations are put in boxes with a blue shadow


How to make that work? (I think I do not know how to use ifx to make that work)



EDIT: I also tried:



ifdefinedshadow
shadow={2pt}{-2pt}{0mm}{shadow},
fi


but it does not work either










share|improve this question

























  • One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

    – marmot
    3 hours ago











  • You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

    – Kpym
    3 hours ago













  • @Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

    – Vincent
    3 hours ago













  • I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

    – Kpym
    3 hours ago














0












0








0








I am trying to design a small package, mostly for test purpose. Currently the package looks like this:



% eqbox.sty
NeedsTeXFormat{LaTeX2e}[1994/06/01]
ProvidesPackage{eqbox}[2019/01/01 Boxed Equations]

RequirePackage{xcolor}
RequirePackage{pgfopts}
RequirePackage{amsmath}
RequirePackage{fancybox}
RequirePackage[most]{tcolorbox}

pgfkeys{
/eqbox/.cd,
colframe/.store in = colframe,
colframe = black,
colback/.store in = colback,
colback = white,
shadow/.store in = shadow,
shadow = undefined,
}
ProcessPgfPackageOptions{/eqbox}

tcbset{
highlight math style={
enhanced,
sharp corners,
breakable,
colframe=colframe,
colback=colback,
ifxundefinedshadow
else
shadow={2pt}{-2pt}{0mm}{shadow},
fi
boxrule=0.4pt,
boxsep = 3pt,
left = 0pt,
right = 0pt,
top = 0pt,
bottom = 0pt
}
}


and I can try to use it this way:



documentclass[letterpaper, 11pt, onecolumn]{article}

usepackage{lipsum}
usepackage{eqbox}

begin{document}
lipsum[1]
begin{equation}
tcbhighmath{x^2 + 3}
end{equation}
lipsum[1]
end{document}


However it does not work. My intent is that:




  • By default, usepackage{eqbox} does not provide any shadow

  • If the user writes usepackage[shadow=blue]{eqbox} then equations are put in boxes with a blue shadow


How to make that work? (I think I do not know how to use ifx to make that work)



EDIT: I also tried:



ifdefinedshadow
shadow={2pt}{-2pt}{0mm}{shadow},
fi


but it does not work either










share|improve this question
















I am trying to design a small package, mostly for test purpose. Currently the package looks like this:



% eqbox.sty
NeedsTeXFormat{LaTeX2e}[1994/06/01]
ProvidesPackage{eqbox}[2019/01/01 Boxed Equations]

RequirePackage{xcolor}
RequirePackage{pgfopts}
RequirePackage{amsmath}
RequirePackage{fancybox}
RequirePackage[most]{tcolorbox}

pgfkeys{
/eqbox/.cd,
colframe/.store in = colframe,
colframe = black,
colback/.store in = colback,
colback = white,
shadow/.store in = shadow,
shadow = undefined,
}
ProcessPgfPackageOptions{/eqbox}

tcbset{
highlight math style={
enhanced,
sharp corners,
breakable,
colframe=colframe,
colback=colback,
ifxundefinedshadow
else
shadow={2pt}{-2pt}{0mm}{shadow},
fi
boxrule=0.4pt,
boxsep = 3pt,
left = 0pt,
right = 0pt,
top = 0pt,
bottom = 0pt
}
}


and I can try to use it this way:



documentclass[letterpaper, 11pt, onecolumn]{article}

usepackage{lipsum}
usepackage{eqbox}

begin{document}
lipsum[1]
begin{equation}
tcbhighmath{x^2 + 3}
end{equation}
lipsum[1]
end{document}


However it does not work. My intent is that:




  • By default, usepackage{eqbox} does not provide any shadow

  • If the user writes usepackage[shadow=blue]{eqbox} then equations are put in boxes with a blue shadow


How to make that work? (I think I do not know how to use ifx to make that work)



EDIT: I also tried:



ifdefinedshadow
shadow={2pt}{-2pt}{0mm}{shadow},
fi


but it does not work either







tikz-pgf tcolorbox package-writing ifthenelse






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









Bernard

173k776205




173k776205










asked 4 hours ago









VincentVincent

1,79021937




1,79021937













  • One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

    – marmot
    3 hours ago











  • You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

    – Kpym
    3 hours ago













  • @Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

    – Vincent
    3 hours ago













  • I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

    – Kpym
    3 hours ago



















  • One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

    – marmot
    3 hours ago











  • You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

    – Kpym
    3 hours ago













  • @Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

    – Vincent
    3 hours ago













  • I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

    – Kpym
    3 hours ago

















One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

– marmot
3 hours ago





One quick remark: you have shadow = undefined, but a backslash in ifxundefinedshadow. (I am not saying that adding the backslash will fix it.)

– marmot
3 hours ago













You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

– Kpym
3 hours ago







You can add ifxshadowemptyelsetcbset{shadow={2pt}{-2pt}{0mm}{shadow}}fi outside of tcbset. And then simply set shadow= (to set the shadow to empty) or shadow=red to set it to red. But I do not understand why you need the shadow macro to do all this. You can simply set /eqbox/shadow/.style = {shadow={2pt}{-2pt}{0mm}{#1}}.

– Kpym
3 hours ago















@Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

– Vincent
3 hours ago







@Kpym: would there be any trick to put the ifx/else inside the tcbset. In this specific case your trick works, but I'm sure I will encounter cases where I would like to have if/else conditions inside some command.

– Vincent
3 hours ago















I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

– Kpym
3 hours ago





I can't see why you need to put conditionals directly inside pgfset, tcbset, tikzset. The conditionals should be in the .code part of the keys in general or outside this "key" environments.

– Kpym
3 hours ago










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%2f480580%2fconditionally-include-a-line-based-on-an-option-with-pgfpackages%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%2f480580%2fconditionally-include-a-line-based-on-an-option-with-pgfpackages%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

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)