Using varwidth within an environment definition with minted The Next CEO of Stack...

What is the value of α and β in a triangle?

Recycling old answers

Domestic-to-international connection at Orlando (MCO)

Rotate a column

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

Why the difference in type-inference over the as-pattern in two similar function definitions?

Does increasing your ability score affect your main stat?

How did people program for Consoles with multiple CPUs?

Does falling count as part of my movement?

What happened in Rome, when the western empire "fell"?

Why do remote US companies require working in the US?

Is French Guiana a (hard) EU border?

What did we know about the Kessel run before the prequels?

is it ok to reduce charging current for li ion 18650 battery?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

Need help understanding a power circuit (caps and diodes)

What flight has the highest ratio of time difference to flight time?

Is it professional to write unrelated content in an almost-empty email?

RigExpert AA-35 - Interpreting The Information

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

How do I align (1) and (2)?

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?

The exact meaning of 'Mom made me a sandwich'



Using varwidth within an environment definition with minted



The Next CEO of Stack OverflowUsing minted to define a new environmentNew environment with mintedminted Environment Inside minipage Environmentminted Environment Inside varwidth EnvironmentMinted In A New EnvironmentCombining varwidth with hangindentHow to let minted break across pages but keep the caption together with the end of listing?Minted in new environmentVertical padding for multiline cells using varwidthproblem with varwidth package












0















I'm trying to create a new environment which holds a centered code snippet using minted. Firstly I came across to a minipage package, however it needs the width specification. I just want it to be dynamic according to it's content length. So I picked varwidth which seemed doing exactly what I need. But when I try to put it like:



newenvironment{ra}[3][]{
VerbatimEnvironment
begin{listing}
caption{#2}
label{#3}
begin{center}
begin{varwidth}{15em}
begin{minted}[escapeinside=||,
mathescape=true,
autogobble,
frame=single,
style=vs,
#1]{text}}
{
end{minted}
end{varwidth}
end{center}
end{listing}
}


It just behaves the same way as minipage does. Does not adjust at all. Usage:



begin{ra}{some caption}{code:label}
Example
end{ra}


Am I doing anything wrong? Thanks










share|improve this question







New contributor




marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I'm trying to create a new environment which holds a centered code snippet using minted. Firstly I came across to a minipage package, however it needs the width specification. I just want it to be dynamic according to it's content length. So I picked varwidth which seemed doing exactly what I need. But when I try to put it like:



    newenvironment{ra}[3][]{
    VerbatimEnvironment
    begin{listing}
    caption{#2}
    label{#3}
    begin{center}
    begin{varwidth}{15em}
    begin{minted}[escapeinside=||,
    mathescape=true,
    autogobble,
    frame=single,
    style=vs,
    #1]{text}}
    {
    end{minted}
    end{varwidth}
    end{center}
    end{listing}
    }


    It just behaves the same way as minipage does. Does not adjust at all. Usage:



    begin{ra}{some caption}{code:label}
    Example
    end{ra}


    Am I doing anything wrong? Thanks










    share|improve this question







    New contributor




    marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I'm trying to create a new environment which holds a centered code snippet using minted. Firstly I came across to a minipage package, however it needs the width specification. I just want it to be dynamic according to it's content length. So I picked varwidth which seemed doing exactly what I need. But when I try to put it like:



      newenvironment{ra}[3][]{
      VerbatimEnvironment
      begin{listing}
      caption{#2}
      label{#3}
      begin{center}
      begin{varwidth}{15em}
      begin{minted}[escapeinside=||,
      mathescape=true,
      autogobble,
      frame=single,
      style=vs,
      #1]{text}}
      {
      end{minted}
      end{varwidth}
      end{center}
      end{listing}
      }


      It just behaves the same way as minipage does. Does not adjust at all. Usage:



      begin{ra}{some caption}{code:label}
      Example
      end{ra}


      Am I doing anything wrong? Thanks










      share|improve this question







      New contributor




      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm trying to create a new environment which holds a centered code snippet using minted. Firstly I came across to a minipage package, however it needs the width specification. I just want it to be dynamic according to it's content length. So I picked varwidth which seemed doing exactly what I need. But when I try to put it like:



      newenvironment{ra}[3][]{
      VerbatimEnvironment
      begin{listing}
      caption{#2}
      label{#3}
      begin{center}
      begin{varwidth}{15em}
      begin{minted}[escapeinside=||,
      mathescape=true,
      autogobble,
      frame=single,
      style=vs,
      #1]{text}}
      {
      end{minted}
      end{varwidth}
      end{center}
      end{listing}
      }


      It just behaves the same way as minipage does. Does not adjust at all. Usage:



      begin{ra}{some caption}{code:label}
      Example
      end{ra}


      Am I doing anything wrong? Thanks







      environments minipage minted varwidth






      share|improve this question







      New contributor




      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 14 mins ago









      marthin23marthin23

      1




      1




      New contributor




      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      marthin23 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          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
          });


          }
          });






          marthin23 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482333%2fusing-varwidth-within-an-environment-definition-with-minted%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








          marthin23 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          marthin23 is a new contributor. Be nice, and check out our Code of Conduct.













          marthin23 is a new contributor. Be nice, and check out our Code of Conduct.












          marthin23 is a new contributor. Be nice, and check out our Code of Conduct.
















          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%2f482333%2fusing-varwidth-within-an-environment-definition-with-minted%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

          IEEEtran - How to include ORCID in TeX/PDF with PdfLatexIs there a standard way to include ORCID in TeX /...

          Cicindela nigrior Przypisy | Menu nawigacyjneCicindela varians unicolorManual for the Identification of the...

          Glossaries-extra: Adding glossaries package to “Clas­sicTh­e­sis” template by Dr. André Miede v. 4.6 ...