\begin{document}
\tableofcontents
\section{No-closing section}
In nova fert animus
\begin{section}
[environment-style section for the toc]
{environment-style section}
\begin{par}
test test test test test test test test test test test test test test
test test test test
\end{par}
\begin{par}
test test test test test test test test test test test test test test
test test test test test
\end{par}
\end{section}
% \begin{section*}
% {starred environment-style section}
% Too bad this doesn't work\textellipsis
% \end{section*}
\end{document}
\endinput
Is it correct that there is no starred version of environment-form of
chapters/sections/...? (They are handy in a code-folding context.)
Is it possible/easy to define them? (...In a portable way, so that
packages messing with sectioning and headings don't get confused.)
Erik
Why do you think it exists any environment-form? Your speculation is wrong.
...Rolf
> Is it correct that there is no starred version of environment-form of
> chapters/sections/...? (They are handy in a code-folding context.)
>
> Is it possible/easy to define them? (...In a portable way, so that
> packages messing with sectioning and headings don't get confused.)
ROTFL
If you are convinced that such a thing is needed, how about this one? :-)
Ulrich
\documentclass{article}
\expandafter\newcommand
\expandafter*%
\csname section*\endcsname{\section*}
\begin{document}
\begin{section*}
{starred environment-style section}
Too bad this doesn't work\textellipsis
\end{section*}
\end{document}
On Wed, 29 Aug 2007, Rolf Niepraschk wrote:
>
> Why do you think it exists any environment-form? Your speculation is wrong.
Do you mean to suggest I didn't try out my minimal example before posting
it? May I assume that you didn't try out my minimal example? May I suggest
you do before hurting my feelings (snif snif :-( ) by calling my post
speculative?
But Rolf, no hard feelings, ;-)
Erik
On Thu, 30 Aug 2007, Ulrich Diez wrote:
>
> ROTFL
>
> If you are convinced that such a thing is needed, ...
Well, it is useful for code-folding in Kile, which I like to use.
Genuinly: Is it so far out to think of using such a construct? (I give a
minimal example of naive but illustrative scope-delimiting at the end of
this post.)
> ... how about this one? :-)
> [...]
Thanks, Ulrich, your solution works.
Erik
P.S.: perhaps I should ask the LaTeX3 team to include it in their next
LaTeX2e update...
P.S.S.: minimal example:
---
\documentclass{article}
\expandafter\newcommand
\expandafter*%
\csname section*\endcsname{\section*}
\begin{document}
\begin{section*}
{starred environment-style section}
\itshape
Thanks to Ulrich, this works.
\end{section*}
Could be useful, a way to delimit scopes, no?
\end{document}
---
>> Erik Quaeghebeur schrieb:
>> ...
>>>
>>> Is it correct that there is no starred version of environment-form of
>>> chapters/sections/...? (They are handy in a code-folding context.)
>> Why do you think it exists any environment-form? Your speculation is wrong.
>
> Do you mean to suggest I didn't try out my minimal example before posting
> it? May I assume that you didn't try out my minimal example? May I suggest
> you do before hurting my feelings (snif snif :-( ) by calling my post
> speculative?
Did you try if the possibility to use \begin{something} means really
that an environment has been defined?
You can use \begin{command} for almost every command:
\documentclass{minimal}
\newcommand\mycommand{Test}
\begin{document}
\mycommand
\begin{mycommand}
a text
\end{mycommand}
\begin{center}
text
\end{center}
\begin{center}
text
\endcenter %works fine
\begin{mycommand}
a text
\endmycommand %gives error
\end{document}
--
Ulrike Fischer
> Is it correct that there is no starred version of environment-form of
> chapters/sections/...? (They are handy in a code-folding context.)
>
> Is it possible/easy to define them? (...In a portable way, so that
> packages messing with sectioning and headings don't get confused.)
A few weeks ago I posted it here (but I'm unable to find
the post on Google):
\newenvironment{section*}{\section*}{}
Javier
-----------------------------
http://www.texytipografia.com
Yes, I'm starting to like this style the more I think about it.
> P.S.: perhaps I should ask the LaTeX3 team to include it in their next
> LaTeX2e update...
Well, we could write a package for it, but I doubt it will be added to
the LaTeX kernel. In fact, I'd be interested in putting a package
together. I notice that Heiko Oberdiek posted a skeleton relsec.sty to
the group back in 2000.
> \expandafter\newcommand
> \expandafter*%
> \csname section*\endcsname{\section*}
\newenvironment{section*}{\section*}{}
is better (i.e., shorter). (Thanks Javier:
<http://groups.google.com/group/comp.text.tex/msg/1458a5a7745aaa51>)
Will
[on \begin{section*} ... \end{section*}]:
> Well, it is useful for code-folding in Kile, which I like to use.
> Genuinly: Is it so far out to think of using such a construct? (I give a
> minimal example of naive but illustrative scope-delimiting at the end of
> this post.)
Well, then, fix Kile, not LaTeX, to handle this kind of things. The
Mac Editor BBEdit knows how to fold sections using standard LaTeX
syntax, so it is not impossible...
Maarten
> > > Is it correct that there is no starred version of environment-form of
> > > chapters/sections/...? (They are handy in a code-folding context.)
> P.S.: perhaps I should ask the LaTeX3 team to include it in their next
> LaTeX2e update...
\newenvironment is already there, also the star form of \section
exists. There isn't a point having an environment "section*", unless
you use an own class with changed semantics.
Yours sincerely
Heiko <ober...@uni-freiburg.de>
On Thu, 30 Aug 2007, Maarten wrote:
>
> Well, then, fix Kile, not LaTeX, to handle this kind of things. The
> Mac Editor BBEdit knows how to fold sections using standard LaTeX
> syntax, so it is not impossible...
Maarten, you are right that this is possible and perhaps preferable.
However, I do not have the coding skills (I think) or the inclination to
add this feature to Kile; perhaps one day... I know Kile-developers have
looked at it, but probably found it too much of a hassle to implement it
(yet).
Code folding got me started on this, but there might be other uses, as I
alluded to in my grandparent post (have a look at the included minimal
example if you want):
> > Genuinly: Is it so far out to think of using such a construct? (I give a
> > minimal example of naive but illustrative scope-delimiting at the end of
> > this post.)
I see no convincing reason to say that adding (starred) environment-form
(perhaps I better call this scoped-form) sectioning commands to LaTeX
would be a bad idea; perhaps code complexity increase for package writers,
or confusion for new LaTeX user might be.
Erik
No, not then. The problem is that I don't know what you mean with "means
really that an environment has been defined". I'm probably showing that I
know more (even if it turns out not to be that much) about the 'La' part
in LaTeX than the 'TeX' part: (but it was a LaTeX-question)
First, I thought an environment behaved like something defined with the
\newenvironment command:
---
\documentclass{article}
\newenvironment{sayhelloandbye}{hello }{ bye\\}
\begin{document}
\begin{sayhelloandbye}
Don't interrupt! I'm in the middle of an environment.
\end{sayhelloandbye}
\begin{sayhelloandbye}
Don't interrupt! I'm in the middle of an environment.
\endsayhelloandbye % seems to end the environment, but
% problematically (i.e., without TeX being aware?)
Please interrupt! I'm outside of the environment.
\end{document}
---
Bluntly: it creates a scope (like {} creates a scope) with something
around it. \begin{section}{} \end{section} does that.
I was not aware that a real environment must have an
\endenvironmentname-command associated. Or perhaps this is so for TeX
environments?
> You can use \begin{command} for almost every command:
>
> [... snipped actual minimal example ...]
Interesting, thank you for pointing this out. But I don't get the point of
your example with relation to my original question. Moreover, I think that
something is not working fine in your example:
Modified version of Ulrike's minimal example (my modifications indicated
by % EQ)
---
\documentclass{minimal}
\newcommand\mycommand{Test}
\begin{document}
\mycommand
\begin{mycommand}
a text
\end{mycommand}
\begin{center}
text
\end{center}
This must not be centered. % EQ
\begin{center}
text
\endcenter %works fine
This should not be centered if \verb+\endcenter+ works fine, % EQ
or am I wrong?\\ (It is centered for me...) % EQ
\begin{mycommand}
a text
\endmycommand %gives error
post-\verb+\endmycommand+-testword % EQ
\begin{mycommand} % EQ
a text % EQ
\endmycommand %gives error % EQ
% EQ: the same behavior as \endcenter,
% EQ: but this time verbosely logged?
\end{document}
---
Erik
On Thu, 30 Aug 2007, Javier Bezos wrote:
>
> A few weeks ago I posted it here (but I'm unable to find
> the post on Google):
>
> \newenvironment{section*}{\section*}{}
Great, thanks Javier. (N.B.: Will Robertson points to your post in another
message in this thread. So also thanks to Will.)
Erik
>> You can use \begin{command} for almost every command:
>>
>> [... snipped actual minimal example ...]
>
> Interesting, thank you for pointing this out. But I don't get the point of
> your example with relation to my original question. Moreover, I think that
> something is not working fine in your example:
It wasn't meant as a answer to your original question but was a
reaction to your snippish answer to Rolf's remark.
There is no environment "section". That
\begin{section}--\end{section} works more or less as you expect is
is a side effect of the way \begin and \end work. And this
"side-effect" doesn't work with \section*.
> This must not be centered. % EQ
>
> \begin{center}
> text
> \endcenter %works fine
That's a misunderstanding. The example should only show you that in
a real environment \end<command> is defined (that's why you can use
e.g. \center -- \endcenter internally when defining new
environments.
But \center is not equal to \begin{center}: it doesn't start a
group. And \endcenter doesn't end a group so is not the same as
\end{center}. So you will have to use
\begin{center}
text
\endcenter\endgroup
--
Ulrike Fischer
> On Thu, 30 Aug 2007, Ulrike Fischer wrote:
[...]
> I was not aware that a real environment must have an
> \endenvironmentname-command associated. Or perhaps this is so for TeX
> environments?
>
> > You can use \begin{command} for almost every command:
> >
> > [... snipped actual minimal example ...]
>
> Interesting, thank you for pointing this out.
If you like interesting environments - did you already hear
about the csname-environment? :-)
\documentclass{article}
\newcommand*\hello{Hi!}
\begin{document}
\begin{csname}hello\end{csname}
\begin{csname}TeX\end{csname}
is funny sometimes!
\end{document}
The crucial point: Afaik it only works with control-sequences that
don't take arguments...
Sincerely
Ulrich
On Thu, 30 Aug 2007, Ulrike Fischer wrote:
>
> It wasn't meant as a answer to your original question but was a
> reaction to your snippish answer to Rolf's remark.
Ok. Sorry for that (also to Rolf), I did not mean to come across snippish
(ouch, ad hominem, did you really mean that?), but sarcastic and then
conciliatory (to compensate for the sarcasm). (Note to self: watch out
even more with non-neutral comments.) The sarcasm was triggered by the
curtness of Rolf's remark, which contained no clue whatsoever to what
you've now made clearer to me. (Ok, enough excuses...)
> There is no environment "section". That
> \begin{section}--\end{section} works more or less as you expect is
> is a side effect of the way \begin and \end work. And this
> "side-effect" doesn't work with \section*.
So is it überhaupt possible to define a real section environment that
works with \begin{}--\end{}? It seems there is a conflict with the fact
that the \section command allows a non-real environment to be formed by
using \begin{}--\end{}. Is there any practical difference between a real
environment and a \begin{}--\end{} version of a command?
Also, I'm curious, what are the names of the commands
\beginenvironmentname,\endenvironmenname generated by invoking
\newenvironment{section}{\section}{}?
BTW, thanks for the other educating remarks (I did not cite).
Erik
> Also, I'm curious, what are the names of the commands
> \beginenvironmentname,\endenvironmenname generated by invoking
> \newenvironment{section}{\section}{}?
\newenvironment{foo}{<begin-text>}{<end-text>}
will define the macro \foo to expand to <begin-text>
will define the macro \endfoo to expand to <end-text>
Calling the environment via \begin{foo}..\end{foo}
leads to checking if the macro \foo is defined.
If not:
Error-message.
If so:
Open a new scope/group, save the current environment-name
within that scope, execute within that scope the macro \foo
If \end{foo} is encountered, this will check if the argument-name
"foo" equals the current environment-name.
If not:
Error-message.
If so:
Execute \csname endfoo\endcsname and afterwards close the new scope.
Calling \endfoo in terms of \csname..\endcsname has the side-effect that
in case \endfoo (e.g., \endsection) is not defined, \csname will define it
to equal \relax within the local scope.
Your special case is a sad thing:
\newenvironment{section}{\section}{}
This tries to define the macros \section and \endsection.
Because the \section-macro is already defined, you get an error-message
about the macro \section already being defined.
If you had written
\renewenvironment{section}{\section}{}
, this would have defined the macro \endsection to expand to
nothing/emptiness and it would have redefined the macro \sectio
to expand to itself.
Thus calling this environment would result in an endless-loop.
Sincerely
Ulrich