capture=hbox inside newtcblisting doesn't work












1















I can include a minted listing inside a tikz node using newtcblisting from the tcolorbox package. However, when I do that it takes all horizontal space available, because the default is to use minipage. So I tried to use capture=hbox as an option to newtcblisting, but it doesn't seem to work.



documentclass{article}

usepackage{tikz}
usepackage{minted}
usepackage{tcolorbox}
tcbuselibrary{minted}
definecolor{codebggray}{rgb}{0.8,0.8,0.8}

newtcblisting{codenode}[2]{%
colback=codebggray,
capture=hbox,
listing only,
minted options={
fontsize=small
},
minted language=#2,
#1
}

begin{document}

Inside a tikz node:

begin{tikzpicture}[node distance=3cm]
node(x) {
begin{codenode}{python}
def sum (x,y):
return x + y
end{codenode}
};
node(y) [below of=x]{whatever};
draw (x) -- (y);
end{tikzpicture}

Okay, done.

end{document}


With that code, I get the following error:



...
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./_minted-minted-test/default-pyg-prefix.pygstyle)
(./_minted-minted-test/default.pygstyle)
(./_minted-minted-test/5274B8282787B54746A9B53E7030D876B61BC921347B2DF172485E3E034D065E.pygtex

! LaTeX Error: Something's wrong--perhaps a missing item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.1 begin{Verbatim}[commandchars=\{}]

?


I know I can include a minipage inside the tikz node, but then, as far as I understand, I would need to include the width for each node -- and since I'm working on a 500-page document full of nodes, I'd rather only change the environment definition, not how it's used in the text.



So, is it possible to use capture=hbox inside newtcblisting?










share|improve this question


















  • 1





    Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

    – marmot
    Apr 2 at 17:58






  • 1





    At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

    – quark67
    Apr 2 at 18:23






  • 1





    As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

    – Ignasi
    Apr 2 at 18:46













  • Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

    – Jay
    Apr 2 at 18:59
















1















I can include a minted listing inside a tikz node using newtcblisting from the tcolorbox package. However, when I do that it takes all horizontal space available, because the default is to use minipage. So I tried to use capture=hbox as an option to newtcblisting, but it doesn't seem to work.



documentclass{article}

usepackage{tikz}
usepackage{minted}
usepackage{tcolorbox}
tcbuselibrary{minted}
definecolor{codebggray}{rgb}{0.8,0.8,0.8}

newtcblisting{codenode}[2]{%
colback=codebggray,
capture=hbox,
listing only,
minted options={
fontsize=small
},
minted language=#2,
#1
}

begin{document}

Inside a tikz node:

begin{tikzpicture}[node distance=3cm]
node(x) {
begin{codenode}{python}
def sum (x,y):
return x + y
end{codenode}
};
node(y) [below of=x]{whatever};
draw (x) -- (y);
end{tikzpicture}

Okay, done.

end{document}


With that code, I get the following error:



...
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./_minted-minted-test/default-pyg-prefix.pygstyle)
(./_minted-minted-test/default.pygstyle)
(./_minted-minted-test/5274B8282787B54746A9B53E7030D876B61BC921347B2DF172485E3E034D065E.pygtex

! LaTeX Error: Something's wrong--perhaps a missing item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.1 begin{Verbatim}[commandchars=\{}]

?


I know I can include a minipage inside the tikz node, but then, as far as I understand, I would need to include the width for each node -- and since I'm working on a 500-page document full of nodes, I'd rather only change the environment definition, not how it's used in the text.



So, is it possible to use capture=hbox inside newtcblisting?










share|improve this question


















  • 1





    Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

    – marmot
    Apr 2 at 17:58






  • 1





    At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

    – quark67
    Apr 2 at 18:23






  • 1





    As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

    – Ignasi
    Apr 2 at 18:46













  • Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

    – Jay
    Apr 2 at 18:59














1












1








1


1






I can include a minted listing inside a tikz node using newtcblisting from the tcolorbox package. However, when I do that it takes all horizontal space available, because the default is to use minipage. So I tried to use capture=hbox as an option to newtcblisting, but it doesn't seem to work.



documentclass{article}

usepackage{tikz}
usepackage{minted}
usepackage{tcolorbox}
tcbuselibrary{minted}
definecolor{codebggray}{rgb}{0.8,0.8,0.8}

newtcblisting{codenode}[2]{%
colback=codebggray,
capture=hbox,
listing only,
minted options={
fontsize=small
},
minted language=#2,
#1
}

begin{document}

Inside a tikz node:

begin{tikzpicture}[node distance=3cm]
node(x) {
begin{codenode}{python}
def sum (x,y):
return x + y
end{codenode}
};
node(y) [below of=x]{whatever};
draw (x) -- (y);
end{tikzpicture}

Okay, done.

end{document}


With that code, I get the following error:



...
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./_minted-minted-test/default-pyg-prefix.pygstyle)
(./_minted-minted-test/default.pygstyle)
(./_minted-minted-test/5274B8282787B54746A9B53E7030D876B61BC921347B2DF172485E3E034D065E.pygtex

! LaTeX Error: Something's wrong--perhaps a missing item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.1 begin{Verbatim}[commandchars=\{}]

?


I know I can include a minipage inside the tikz node, but then, as far as I understand, I would need to include the width for each node -- and since I'm working on a 500-page document full of nodes, I'd rather only change the environment definition, not how it's used in the text.



So, is it possible to use capture=hbox inside newtcblisting?










share|improve this question














I can include a minted listing inside a tikz node using newtcblisting from the tcolorbox package. However, when I do that it takes all horizontal space available, because the default is to use minipage. So I tried to use capture=hbox as an option to newtcblisting, but it doesn't seem to work.



documentclass{article}

usepackage{tikz}
usepackage{minted}
usepackage{tcolorbox}
tcbuselibrary{minted}
definecolor{codebggray}{rgb}{0.8,0.8,0.8}

newtcblisting{codenode}[2]{%
colback=codebggray,
capture=hbox,
listing only,
minted options={
fontsize=small
},
minted language=#2,
#1
}

begin{document}

Inside a tikz node:

begin{tikzpicture}[node distance=3cm]
node(x) {
begin{codenode}{python}
def sum (x,y):
return x + y
end{codenode}
};
node(y) [below of=x]{whatever};
draw (x) -- (y);
end{tikzpicture}

Okay, done.

end{document}


With that code, I get the following error:



...
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./_minted-minted-test/default-pyg-prefix.pygstyle)
(./_minted-minted-test/default.pygstyle)
(./_minted-minted-test/5274B8282787B54746A9B53E7030D876B61BC921347B2DF172485E3E034D065E.pygtex

! LaTeX Error: Something's wrong--perhaps a missing item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.1 begin{Verbatim}[commandchars=\{}]

?


I know I can include a minipage inside the tikz node, but then, as far as I understand, I would need to include the width for each node -- and since I'm working on a 500-page document full of nodes, I'd rather only change the environment definition, not how it's used in the text.



So, is it possible to use capture=hbox inside newtcblisting?







tikz-pgf boxes tcolorbox






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 2 at 16:37









JayJay

1,45811635




1,45811635








  • 1





    Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

    – marmot
    Apr 2 at 17:58






  • 1





    At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

    – quark67
    Apr 2 at 18:23






  • 1





    As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

    – Ignasi
    Apr 2 at 18:46













  • Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

    – Jay
    Apr 2 at 18:59














  • 1





    Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

    – marmot
    Apr 2 at 17:58






  • 1





    At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

    – quark67
    Apr 2 at 18:23






  • 1





    As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

    – Ignasi
    Apr 2 at 18:46













  • Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

    – Jay
    Apr 2 at 18:59








1




1





Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

– marmot
Apr 2 at 17:58





Hope you are not getting mad at me, but: in order to answer this question (and to be sure that the answer works) you are expecting the answerer to be familiar with TikZ and tcolorbox and have pygmentize installed. You may very well find users meeting these criteria, but IMHO it would be advantageous to split the problem in smaller parts such that more users can conceivably answer. (For instance, I am concerned that putting a tcolorbox in a node nests tikzpictures but I have no chance of checking if this has anything to do with your problem because I do not have pygmentize installed.)

– marmot
Apr 2 at 17:58




1




1





At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

– quark67
Apr 2 at 18:23





At this bug report, we read from the developer: While listings can be put into a hbox (which is used internally in your code), minted cannot.

– quark67
Apr 2 at 18:23




1




1





As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

– Ignasi
Apr 2 at 18:46







As marmot explained nesting tikzpictures is not a good recomendation, therefore a tcolorbox inside a tikzpicture could not be the best solution. If you explain why do you want it or what do you want to build, may be we could offer alternative constructions.

– Ignasi
Apr 2 at 18:46















Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

– Jay
Apr 2 at 18:59





Thanks for all who answered. I realize this is not a simple thing to do; now, since I can make it work by including a minipage inside each tikz node, I'll try to get that done someiautomatically.

– Jay
Apr 2 at 18:59










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%2f482810%2fcapture-hbox-inside-newtcblisting-doesnt-work%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%2f482810%2fcapture-hbox-inside-newtcblisting-doesnt-work%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

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?