Span command across LaTeX environmentsHow does LaTeX implement environments?Creating Command with environmentsIndenting text and still allowing sections, pagebreaks and floatsDefining New Environments using a CommandStarting environment with beginenv or with envChange background color across different environmentsLabelling Theorem Environments across documentsSetting new environments with LaTeXCommand for aliasing environments

Which act of Congress authorized the Ukrainian aid which was allegedly withheld?

Why did the Bohr Model Successfully calculate some of the energy levels in hydrogen?

Why does nobody understand the grapple rules?

Completing the square to solve limit problems

What happened to Sophie in her last encounter with Arthur?

How to understand Generative Adversarial Networks Discriminative distribution?

table Undefined control sequence

Log monitoring with pythonic tail -f and process killing

Is this a pure function?

Time machine in Interstellar movie

PBKDF2 with SHA-256/512 for low entropy input?

Is there any point in adding more than 6 months' runway in savings instead of investing everything after that?

What type of rhetorical device is the offering of a source which is really long and not specifying what part of the source is relevant?

What are these criss-cross patterns close to Cambridge Airport (UK)?

プレゼント買う心配がありません without particles

What do you call someone whose unmarried partner has died?

How to communicate faster than the system clock

What type of beer is best for beer battered fish?

Why was the DC-9-80 so successful despite being obsolete almost from birth?

50% portfolio in single stock, JPM - appropriate for 80 year old?

Why are Democrats mostly focused on increasing healthcare spending, rarely mentioning any proposals for decreasing the costs of healthcare services?

Is it safe to delete the default "postgres" role?

CO₂ level is high enough that it reduces cognitive ability. Isn't that a reason to worry?

Create virtual block device which writes to /dev/null



Span command across LaTeX environments


How does LaTeX implement environments?Creating Command with environmentsIndenting text and still allowing sections, pagebreaks and floatsDefining New Environments using a CommandStarting environment with beginenv or with envChange background color across different environmentsLabelling Theorem Environments across documentsSetting new environments with LaTeXCommand for aliasing environments






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









6

















Suppose I have an environment redacted which I wanted to declare in such a manner:



beginredacted
This is some secret content.
endredacted


Which, I wanted the result to be equivalent to passing the text inside the environment inside minipage and phantom



beginminipage[1.0textwidth]
phantomThis is some secret content.
endminipage


The following declaration gives me error since the curly parenthesis doesn't match up



newenvironmentredacted

beginminipage[1.0textwidth]
phantom



endminipage



Are there any ways to achieve this?










share|improve this question





















  • 3





    Are you familiar with the comment package and its comment environment?

    – Mico
    Jul 24 at 5:40











  • I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

    – srakrn
    Jul 24 at 5:42






  • 3





    You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

    – daleif
    Jul 24 at 5:50

















6

















Suppose I have an environment redacted which I wanted to declare in such a manner:



beginredacted
This is some secret content.
endredacted


Which, I wanted the result to be equivalent to passing the text inside the environment inside minipage and phantom



beginminipage[1.0textwidth]
phantomThis is some secret content.
endminipage


The following declaration gives me error since the curly parenthesis doesn't match up



newenvironmentredacted

beginminipage[1.0textwidth]
phantom



endminipage



Are there any ways to achieve this?










share|improve this question





















  • 3





    Are you familiar with the comment package and its comment environment?

    – Mico
    Jul 24 at 5:40











  • I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

    – srakrn
    Jul 24 at 5:42






  • 3





    You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

    – daleif
    Jul 24 at 5:50













6












6








6


0






Suppose I have an environment redacted which I wanted to declare in such a manner:



beginredacted
This is some secret content.
endredacted


Which, I wanted the result to be equivalent to passing the text inside the environment inside minipage and phantom



beginminipage[1.0textwidth]
phantomThis is some secret content.
endminipage


The following declaration gives me error since the curly parenthesis doesn't match up



newenvironmentredacted

beginminipage[1.0textwidth]
phantom



endminipage



Are there any ways to achieve this?










share|improve this question















Suppose I have an environment redacted which I wanted to declare in such a manner:



beginredacted
This is some secret content.
endredacted


Which, I wanted the result to be equivalent to passing the text inside the environment inside minipage and phantom



beginminipage[1.0textwidth]
phantomThis is some secret content.
endminipage


The following declaration gives me error since the curly parenthesis doesn't match up



newenvironmentredacted

beginminipage[1.0textwidth]
phantom



endminipage



Are there any ways to achieve this?







environments






share|improve this question














share|improve this question











share|improve this question




share|improve this question










asked Jul 24 at 5:31









srakrnsrakrn

383 bronze badges




383 bronze badges










  • 3





    Are you familiar with the comment package and its comment environment?

    – Mico
    Jul 24 at 5:40











  • I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

    – srakrn
    Jul 24 at 5:42






  • 3





    You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

    – daleif
    Jul 24 at 5:50












  • 3





    Are you familiar with the comment package and its comment environment?

    – Mico
    Jul 24 at 5:40











  • I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

    – srakrn
    Jul 24 at 5:42






  • 3





    You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

    – daleif
    Jul 24 at 5:50







3




3





Are you familiar with the comment package and its comment environment?

– Mico
Jul 24 at 5:40





Are you familiar with the comment package and its comment environment?

– Mico
Jul 24 at 5:40













I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

– srakrn
Jul 24 at 5:42





I'm aware of the comment environment. However, phantom, to my understanding, leaves empty spaces in the text area while comment doesn't.

– srakrn
Jul 24 at 5:42




3




3





You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

– daleif
Jul 24 at 5:50





You have to extract the contents first and then add it to phantom. For example save the minipage in a box (lrbox env, wrapped around the minipage), then use the box inside phantom in the end of the env definition. Generally you cannot span a macro over a begin end env

– daleif
Jul 24 at 5:50










2 Answers
2






active

oldest

votes


















9


















I believe you want something like this. Note that I put the minipage inside phantom and not the other way around, because when called in a non-math mode, phantom typesets its argument in restricted horizontal mode (LR-mode in LaTeX terms), therefore using phantomBODY would always get you one (possibly extremely long) line.



BODY collects the body of the environment declared with NewEnviron. This macro comes from the very convenient environ package.



documentclassarticle
usepackageenviron
usepackagelipsum

NewEnvironredacted%
parnoindent
phantom%
beginminipagelinewidth
BODY
endminipage%
%
par


begindocument

Before.

beginredacted
lipsum[1]
endredacted

After.

enddocument


Screenshot






share|improve this answer

































    7


















    Similar to frougon's answer, another option is to use the xparse package with its b argument type, which first scans the environment body such that it can be used as a normal parameter in the environment definition:



    documentclassarticle
    usepackagexparse
    usepackagelipsum

    NewDocumentEnvironmentredactedb%
    %
    phantom%
    beginminipage1.0textwidth%
    #1%
    endminipage%
    %


    begindocument
    lipsum[1]
    beginredacted
    This is\
    some\
    secret content.
    endredacted
    lipsum[2]
    enddocument


    enter image description here






    share|improve this answer



























      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/4.0/"u003ecc by-sa 4.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%2f501223%2fspan-command-across-latex-environments%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown


























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      9


















      I believe you want something like this. Note that I put the minipage inside phantom and not the other way around, because when called in a non-math mode, phantom typesets its argument in restricted horizontal mode (LR-mode in LaTeX terms), therefore using phantomBODY would always get you one (possibly extremely long) line.



      BODY collects the body of the environment declared with NewEnviron. This macro comes from the very convenient environ package.



      documentclassarticle
      usepackageenviron
      usepackagelipsum

      NewEnvironredacted%
      parnoindent
      phantom%
      beginminipagelinewidth
      BODY
      endminipage%
      %
      par


      begindocument

      Before.

      beginredacted
      lipsum[1]
      endredacted

      After.

      enddocument


      Screenshot






      share|improve this answer






























        9


















        I believe you want something like this. Note that I put the minipage inside phantom and not the other way around, because when called in a non-math mode, phantom typesets its argument in restricted horizontal mode (LR-mode in LaTeX terms), therefore using phantomBODY would always get you one (possibly extremely long) line.



        BODY collects the body of the environment declared with NewEnviron. This macro comes from the very convenient environ package.



        documentclassarticle
        usepackageenviron
        usepackagelipsum

        NewEnvironredacted%
        parnoindent
        phantom%
        beginminipagelinewidth
        BODY
        endminipage%
        %
        par


        begindocument

        Before.

        beginredacted
        lipsum[1]
        endredacted

        After.

        enddocument


        Screenshot






        share|improve this answer




























          9














          9










          9









          I believe you want something like this. Note that I put the minipage inside phantom and not the other way around, because when called in a non-math mode, phantom typesets its argument in restricted horizontal mode (LR-mode in LaTeX terms), therefore using phantomBODY would always get you one (possibly extremely long) line.



          BODY collects the body of the environment declared with NewEnviron. This macro comes from the very convenient environ package.



          documentclassarticle
          usepackageenviron
          usepackagelipsum

          NewEnvironredacted%
          parnoindent
          phantom%
          beginminipagelinewidth
          BODY
          endminipage%
          %
          par


          begindocument

          Before.

          beginredacted
          lipsum[1]
          endredacted

          After.

          enddocument


          Screenshot






          share|improve this answer














          I believe you want something like this. Note that I put the minipage inside phantom and not the other way around, because when called in a non-math mode, phantom typesets its argument in restricted horizontal mode (LR-mode in LaTeX terms), therefore using phantomBODY would always get you one (possibly extremely long) line.



          BODY collects the body of the environment declared with NewEnviron. This macro comes from the very convenient environ package.



          documentclassarticle
          usepackageenviron
          usepackagelipsum

          NewEnvironredacted%
          parnoindent
          phantom%
          beginminipagelinewidth
          BODY
          endminipage%
          %
          par


          begindocument

          Before.

          beginredacted
          lipsum[1]
          endredacted

          After.

          enddocument


          Screenshot







          share|improve this answer













          share|improve this answer




          share|improve this answer










          answered Jul 24 at 6:25









          frougonfrougon

          8,6951 gold badge14 silver badges27 bronze badges




          8,6951 gold badge14 silver badges27 bronze badges


























              7


















              Similar to frougon's answer, another option is to use the xparse package with its b argument type, which first scans the environment body such that it can be used as a normal parameter in the environment definition:



              documentclassarticle
              usepackagexparse
              usepackagelipsum

              NewDocumentEnvironmentredactedb%
              %
              phantom%
              beginminipage1.0textwidth%
              #1%
              endminipage%
              %


              begindocument
              lipsum[1]
              beginredacted
              This is\
              some\
              secret content.
              endredacted
              lipsum[2]
              enddocument


              enter image description here






              share|improve this answer






























                7


















                Similar to frougon's answer, another option is to use the xparse package with its b argument type, which first scans the environment body such that it can be used as a normal parameter in the environment definition:



                documentclassarticle
                usepackagexparse
                usepackagelipsum

                NewDocumentEnvironmentredactedb%
                %
                phantom%
                beginminipage1.0textwidth%
                #1%
                endminipage%
                %


                begindocument
                lipsum[1]
                beginredacted
                This is\
                some\
                secret content.
                endredacted
                lipsum[2]
                enddocument


                enter image description here






                share|improve this answer




























                  7














                  7










                  7









                  Similar to frougon's answer, another option is to use the xparse package with its b argument type, which first scans the environment body such that it can be used as a normal parameter in the environment definition:



                  documentclassarticle
                  usepackagexparse
                  usepackagelipsum

                  NewDocumentEnvironmentredactedb%
                  %
                  phantom%
                  beginminipage1.0textwidth%
                  #1%
                  endminipage%
                  %


                  begindocument
                  lipsum[1]
                  beginredacted
                  This is\
                  some\
                  secret content.
                  endredacted
                  lipsum[2]
                  enddocument


                  enter image description here






                  share|improve this answer














                  Similar to frougon's answer, another option is to use the xparse package with its b argument type, which first scans the environment body such that it can be used as a normal parameter in the environment definition:



                  documentclassarticle
                  usepackagexparse
                  usepackagelipsum

                  NewDocumentEnvironmentredactedb%
                  %
                  phantom%
                  beginminipage1.0textwidth%
                  #1%
                  endminipage%
                  %


                  begindocument
                  lipsum[1]
                  beginredacted
                  This is\
                  some\
                  secret content.
                  endredacted
                  lipsum[2]
                  enddocument


                  enter image description here







                  share|improve this answer













                  share|improve this answer




                  share|improve this answer










                  answered Jul 24 at 6:32









                  siracusasiracusa

                  10.1k2 gold badges20 silver badges41 bronze badges




                  10.1k2 gold badges20 silver badges41 bronze badges































                      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%2f501223%2fspan-command-across-latex-environments%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

                      Tamil (spriik) Luke uk diar | Nawigatjuun

                      Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                      Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?