How can I determine whether a custom environment is followed by a new paragraph?
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I'm writing a custom command that uses minipages to display its contents:
newcommandexample[1]noindentbeginminipagelinewidth#1endminipage
The spacing around this command should be similar to that of the align
environment: abovedisplayskip
above, and belowdisplayskip
after, so I add parvspace…
before and after:
newcommandexample[1]%
parvspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
This isn't perfect, though: it adds an extra parskip
before and after the contents, even if there are no blank lines around the command:
AAA % too much space (extra parskip) after this
examplelipsum[1]
BBB % too much space (extra parskip) before that
I can remove the first one by changing the definition to this:
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
But what's the equivalent fix for the bottom of the command? If I use a negative space the parskip
will always be suppressed. Ideally, I'd like text immediately following the command to not be indented, just like with []
.
Here's a minimal example:
documentclassminimal
usepackagelipsum
setlengthparskip50pt
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
begindocument
% There should be small spaces after AAA and before BBB
AAA
examplelipsum[1]
BBB
% There should be a large space after AAA and a small one before BBB
% And BBB shouldn't be indented
AAA
examplelipsum[1]
BBB
% There should be a small space after AAA and a large one before BBB
AAA
examplelipsum[1]
BBB
enddocument
spacing
add a comment |Â
up vote
5
down vote
favorite
I'm writing a custom command that uses minipages to display its contents:
newcommandexample[1]noindentbeginminipagelinewidth#1endminipage
The spacing around this command should be similar to that of the align
environment: abovedisplayskip
above, and belowdisplayskip
after, so I add parvspace…
before and after:
newcommandexample[1]%
parvspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
This isn't perfect, though: it adds an extra parskip
before and after the contents, even if there are no blank lines around the command:
AAA % too much space (extra parskip) after this
examplelipsum[1]
BBB % too much space (extra parskip) before that
I can remove the first one by changing the definition to this:
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
But what's the equivalent fix for the bottom of the command? If I use a negative space the parskip
will always be suppressed. Ideally, I'd like text immediately following the command to not be indented, just like with []
.
Here's a minimal example:
documentclassminimal
usepackagelipsum
setlengthparskip50pt
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
begindocument
% There should be small spaces after AAA and before BBB
AAA
examplelipsum[1]
BBB
% There should be a large space after AAA and a small one before BBB
% And BBB shouldn't be indented
AAA
examplelipsum[1]
BBB
% There should be a small space after AAA and a large one before BBB
AAA
examplelipsum[1]
BBB
enddocument
spacing
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I'm writing a custom command that uses minipages to display its contents:
newcommandexample[1]noindentbeginminipagelinewidth#1endminipage
The spacing around this command should be similar to that of the align
environment: abovedisplayskip
above, and belowdisplayskip
after, so I add parvspace…
before and after:
newcommandexample[1]%
parvspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
This isn't perfect, though: it adds an extra parskip
before and after the contents, even if there are no blank lines around the command:
AAA % too much space (extra parskip) after this
examplelipsum[1]
BBB % too much space (extra parskip) before that
I can remove the first one by changing the definition to this:
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
But what's the equivalent fix for the bottom of the command? If I use a negative space the parskip
will always be suppressed. Ideally, I'd like text immediately following the command to not be indented, just like with []
.
Here's a minimal example:
documentclassminimal
usepackagelipsum
setlengthparskip50pt
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
begindocument
% There should be small spaces after AAA and before BBB
AAA
examplelipsum[1]
BBB
% There should be a large space after AAA and a small one before BBB
% And BBB shouldn't be indented
AAA
examplelipsum[1]
BBB
% There should be a small space after AAA and a large one before BBB
AAA
examplelipsum[1]
BBB
enddocument
spacing
I'm writing a custom command that uses minipages to display its contents:
newcommandexample[1]noindentbeginminipagelinewidth#1endminipage
The spacing around this command should be similar to that of the align
environment: abovedisplayskip
above, and belowdisplayskip
after, so I add parvspace…
before and after:
newcommandexample[1]%
parvspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
This isn't perfect, though: it adds an extra parskip
before and after the contents, even if there are no blank lines around the command:
AAA % too much space (extra parskip) after this
examplelipsum[1]
BBB % too much space (extra parskip) before that
I can remove the first one by changing the definition to this:
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
But what's the equivalent fix for the bottom of the command? If I use a negative space the parskip
will always be suppressed. Ideally, I'd like text immediately following the command to not be indented, just like with []
.
Here's a minimal example:
documentclassminimal
usepackagelipsum
setlengthparskip50pt
newcommandexample[1]%
ifvmodeelseparvspace-parskipfivspaceabovedisplayskip
noindentbeginminipagelinewidth#1endminipage
paraddvspacebelowdisplayskip
begindocument
% There should be small spaces after AAA and before BBB
AAA
examplelipsum[1]
BBB
% There should be a large space after AAA and a small one before BBB
% And BBB shouldn't be indented
AAA
examplelipsum[1]
BBB
% There should be a small space after AAA and a large one before BBB
AAA
examplelipsum[1]
BBB
enddocument
spacing
spacing
asked 4 hours ago
Clément
1,6861529
1,6861529
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The standard way to do this would be to define your environment as a trivlist
, almost all latex display environments (verbatim, center, quote,..) are defined as trivlists (special one-item version of list) exactly for this reason.
The trivlist code detects whether there is a paragraph break before the list and if so has paragraph spacing before and after, but if there is no paragraph break before the list then the internal par
after the list is hidden and paragraph indentation of the following text is suppressed.
begincenterendcenter
for example is defined by
defcentertrivlist centeringitemrelax
defendcenterendtrivlist
add a comment |Â
up vote
0
down vote
Here is a possible solution.
I'm defining the macro tentativepar
which inserts par
and sets both parskip
and parindent
to 0pt
.
It moreover temporarily redefines par
and everypar
(which is inserted at the start of every paragraph) to reset the original values.
The net effect is that tentativepar
will insert a paragraph break without any skip or indentation unless it is followed by another par
.
Here is an example:
documentclassarticle
setlengthparskip50pt
%% vv We need to store a couple of values
newskipsavedparskip
newskipsavedparindent
newtokssavedeverypar
makeatletter
newcommand*tentativepar%
par
savedparskipparskip %% <- store original parskip
savedparindentparindent %% <- store original parindent
expandaftersavedeveryparexpandaftertheeverypar
%% ^^ store original everypar
parskip0pt %% <- set parskip to 0pt
parindent0pt %% <- set parindent to 0pt
%% vv restore everything that was saved after the first par
defpar%
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
par %% still insert a paragraph break
%
%% vv or at the stat of the next paragraph
expandaftereveryparexpandafter%
thesavedeverypar
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
makeatother
newcommandexample[1]%
ifvmodeelsetentativeparfi
vspaceabovedisplayskip
noindentbeginminipage.5linewidth#1endminipage%
vspacebelowdisplayskip
tentativepar
begindocument
AAA
exampleThere should be small spaces after AAA and before BBB
BBB
AAA
exampleThere should be a large space after AAA and a small one before BBB. And BBB shouldn't be indented.
BBB
AAA
exampleThere should be a small space after AAA and a large one before BBB
BBB
CCC
enddocument
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The standard way to do this would be to define your environment as a trivlist
, almost all latex display environments (verbatim, center, quote,..) are defined as trivlists (special one-item version of list) exactly for this reason.
The trivlist code detects whether there is a paragraph break before the list and if so has paragraph spacing before and after, but if there is no paragraph break before the list then the internal par
after the list is hidden and paragraph indentation of the following text is suppressed.
begincenterendcenter
for example is defined by
defcentertrivlist centeringitemrelax
defendcenterendtrivlist
add a comment |Â
up vote
2
down vote
The standard way to do this would be to define your environment as a trivlist
, almost all latex display environments (verbatim, center, quote,..) are defined as trivlists (special one-item version of list) exactly for this reason.
The trivlist code detects whether there is a paragraph break before the list and if so has paragraph spacing before and after, but if there is no paragraph break before the list then the internal par
after the list is hidden and paragraph indentation of the following text is suppressed.
begincenterendcenter
for example is defined by
defcentertrivlist centeringitemrelax
defendcenterendtrivlist
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The standard way to do this would be to define your environment as a trivlist
, almost all latex display environments (verbatim, center, quote,..) are defined as trivlists (special one-item version of list) exactly for this reason.
The trivlist code detects whether there is a paragraph break before the list and if so has paragraph spacing before and after, but if there is no paragraph break before the list then the internal par
after the list is hidden and paragraph indentation of the following text is suppressed.
begincenterendcenter
for example is defined by
defcentertrivlist centeringitemrelax
defendcenterendtrivlist
The standard way to do this would be to define your environment as a trivlist
, almost all latex display environments (verbatim, center, quote,..) are defined as trivlists (special one-item version of list) exactly for this reason.
The trivlist code detects whether there is a paragraph break before the list and if so has paragraph spacing before and after, but if there is no paragraph break before the list then the internal par
after the list is hidden and paragraph indentation of the following text is suppressed.
begincenterendcenter
for example is defined by
defcentertrivlist centeringitemrelax
defendcenterendtrivlist
answered 3 hours ago
David Carlisle
474k3811031837
474k3811031837
add a comment |Â
add a comment |Â
up vote
0
down vote
Here is a possible solution.
I'm defining the macro tentativepar
which inserts par
and sets both parskip
and parindent
to 0pt
.
It moreover temporarily redefines par
and everypar
(which is inserted at the start of every paragraph) to reset the original values.
The net effect is that tentativepar
will insert a paragraph break without any skip or indentation unless it is followed by another par
.
Here is an example:
documentclassarticle
setlengthparskip50pt
%% vv We need to store a couple of values
newskipsavedparskip
newskipsavedparindent
newtokssavedeverypar
makeatletter
newcommand*tentativepar%
par
savedparskipparskip %% <- store original parskip
savedparindentparindent %% <- store original parindent
expandaftersavedeveryparexpandaftertheeverypar
%% ^^ store original everypar
parskip0pt %% <- set parskip to 0pt
parindent0pt %% <- set parindent to 0pt
%% vv restore everything that was saved after the first par
defpar%
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
par %% still insert a paragraph break
%
%% vv or at the stat of the next paragraph
expandaftereveryparexpandafter%
thesavedeverypar
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
makeatother
newcommandexample[1]%
ifvmodeelsetentativeparfi
vspaceabovedisplayskip
noindentbeginminipage.5linewidth#1endminipage%
vspacebelowdisplayskip
tentativepar
begindocument
AAA
exampleThere should be small spaces after AAA and before BBB
BBB
AAA
exampleThere should be a large space after AAA and a small one before BBB. And BBB shouldn't be indented.
BBB
AAA
exampleThere should be a small space after AAA and a large one before BBB
BBB
CCC
enddocument
add a comment |Â
up vote
0
down vote
Here is a possible solution.
I'm defining the macro tentativepar
which inserts par
and sets both parskip
and parindent
to 0pt
.
It moreover temporarily redefines par
and everypar
(which is inserted at the start of every paragraph) to reset the original values.
The net effect is that tentativepar
will insert a paragraph break without any skip or indentation unless it is followed by another par
.
Here is an example:
documentclassarticle
setlengthparskip50pt
%% vv We need to store a couple of values
newskipsavedparskip
newskipsavedparindent
newtokssavedeverypar
makeatletter
newcommand*tentativepar%
par
savedparskipparskip %% <- store original parskip
savedparindentparindent %% <- store original parindent
expandaftersavedeveryparexpandaftertheeverypar
%% ^^ store original everypar
parskip0pt %% <- set parskip to 0pt
parindent0pt %% <- set parindent to 0pt
%% vv restore everything that was saved after the first par
defpar%
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
par %% still insert a paragraph break
%
%% vv or at the stat of the next paragraph
expandaftereveryparexpandafter%
thesavedeverypar
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
makeatother
newcommandexample[1]%
ifvmodeelsetentativeparfi
vspaceabovedisplayskip
noindentbeginminipage.5linewidth#1endminipage%
vspacebelowdisplayskip
tentativepar
begindocument
AAA
exampleThere should be small spaces after AAA and before BBB
BBB
AAA
exampleThere should be a large space after AAA and a small one before BBB. And BBB shouldn't be indented.
BBB
AAA
exampleThere should be a small space after AAA and a large one before BBB
BBB
CCC
enddocument
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Here is a possible solution.
I'm defining the macro tentativepar
which inserts par
and sets both parskip
and parindent
to 0pt
.
It moreover temporarily redefines par
and everypar
(which is inserted at the start of every paragraph) to reset the original values.
The net effect is that tentativepar
will insert a paragraph break without any skip or indentation unless it is followed by another par
.
Here is an example:
documentclassarticle
setlengthparskip50pt
%% vv We need to store a couple of values
newskipsavedparskip
newskipsavedparindent
newtokssavedeverypar
makeatletter
newcommand*tentativepar%
par
savedparskipparskip %% <- store original parskip
savedparindentparindent %% <- store original parindent
expandaftersavedeveryparexpandaftertheeverypar
%% ^^ store original everypar
parskip0pt %% <- set parskip to 0pt
parindent0pt %% <- set parindent to 0pt
%% vv restore everything that was saved after the first par
defpar%
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
par %% still insert a paragraph break
%
%% vv or at the stat of the next paragraph
expandaftereveryparexpandafter%
thesavedeverypar
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
makeatother
newcommandexample[1]%
ifvmodeelsetentativeparfi
vspaceabovedisplayskip
noindentbeginminipage.5linewidth#1endminipage%
vspacebelowdisplayskip
tentativepar
begindocument
AAA
exampleThere should be small spaces after AAA and before BBB
BBB
AAA
exampleThere should be a large space after AAA and a small one before BBB. And BBB shouldn't be indented.
BBB
AAA
exampleThere should be a small space after AAA and a large one before BBB
BBB
CCC
enddocument
Here is a possible solution.
I'm defining the macro tentativepar
which inserts par
and sets both parskip
and parindent
to 0pt
.
It moreover temporarily redefines par
and everypar
(which is inserted at the start of every paragraph) to reset the original values.
The net effect is that tentativepar
will insert a paragraph break without any skip or indentation unless it is followed by another par
.
Here is an example:
documentclassarticle
setlengthparskip50pt
%% vv We need to store a couple of values
newskipsavedparskip
newskipsavedparindent
newtokssavedeverypar
makeatletter
newcommand*tentativepar%
par
savedparskipparskip %% <- store original parskip
savedparindentparindent %% <- store original parindent
expandaftersavedeveryparexpandaftertheeverypar
%% ^^ store original everypar
parskip0pt %% <- set parskip to 0pt
parindent0pt %% <- set parindent to 0pt
%% vv restore everything that was saved after the first par
defpar%
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
par %% still insert a paragraph break
%
%% vv or at the stat of the next paragraph
expandaftereveryparexpandafter%
thesavedeverypar
@restorepar %% <- restore original par
expandaftereveryparexpandafterthesavedeverypar%
parskipsavedparskip %% <- reset parskip
parindentsavedparindent %% <- reset parindent
makeatother
newcommandexample[1]%
ifvmodeelsetentativeparfi
vspaceabovedisplayskip
noindentbeginminipage.5linewidth#1endminipage%
vspacebelowdisplayskip
tentativepar
begindocument
AAA
exampleThere should be small spaces after AAA and before BBB
BBB
AAA
exampleThere should be a large space after AAA and a small one before BBB. And BBB shouldn't be indented.
BBB
AAA
exampleThere should be a small space after AAA and a large one before BBB
BBB
CCC
enddocument
answered 7 mins ago
Circumscribe
2,268322
2,268322
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458433%2fhow-can-i-determine-whether-a-custom-environment-is-followed-by-a-new-paragraph%23new-answer', 'question_page');
);
Post as a guest
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
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
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