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;
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
add a comment
|
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
3
Are you familiar with thecomment
package and itscomment
environment?
– Mico
Jul 24 at 5:40
I'm aware of thecomment
environment. However,phantom
, to my understanding, leaves empty spaces in the text area whilecomment
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
add a comment
|
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
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
environments
asked Jul 24 at 5:31
srakrnsrakrn
383 bronze badges
383 bronze badges
3
Are you familiar with thecomment
package and itscomment
environment?
– Mico
Jul 24 at 5:40
I'm aware of thecomment
environment. However,phantom
, to my understanding, leaves empty spaces in the text area whilecomment
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
add a comment
|
3
Are you familiar with thecomment
package and itscomment
environment?
– Mico
Jul 24 at 5:40
I'm aware of thecomment
environment. However,phantom
, to my understanding, leaves empty spaces in the text area whilecomment
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
add a comment
|
2 Answers
2
active
oldest
votes
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
add a comment
|
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
add a comment
|
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
);
);
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%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
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
add a comment
|
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
add a comment
|
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
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
answered Jul 24 at 6:25
frougonfrougon
8,6951 gold badge14 silver badges27 bronze badges
8,6951 gold badge14 silver badges27 bronze badges
add a comment
|
add a comment
|
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
add a comment
|
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
add a comment
|
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
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
answered Jul 24 at 6:32
siracusasiracusa
10.1k2 gold badges20 silver badges41 bronze badges
10.1k2 gold badges20 silver badges41 bronze badges
add a comment
|
add a comment
|
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%2f501223%2fspan-command-across-latex-environments%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
3
Are you familiar with the
comment
package and itscomment
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 whilecomment
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