Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

styling an environment

0 views
Skip to first unread message

Alan G Isaac

unread,
Oct 8, 2008, 12:29:41 PM10/8/08
to
In HTML+CSS you can have e.g.

<div class="foo">Some text.</div>
<div class="bar">Other text.</div>

and then use CSS to determine the
display characteristics of div.foo
and div.bar.

This is really useful.
Is there a LaTeX equivalent?
If not, is there an effort to provide
a LaTeX equivalent?

As a point of comparison, consider the
way \newtheorem works. Instead of having
a core theorem environment that takes a class
option to provide styling info, we define a
new environment. This clutters the name space,
hides dependencies, does not allow multiple
classes, etc.

Thanks,
Alan Isaac

Joseph Wright

unread,
Oct 8, 2008, 12:37:09 PM10/8/08
to

Look at the experimental LaTeX3 code, particularly the template
package.
--
Joseph Wright

Alan G Isaac

unread,
Oct 8, 2008, 1:27:21 PM10/8/08
to
On 10/8/2008 12:37 PM Joseph Wright apparently wrote:
> Look at the experimental LaTeX3 code, particularly the template
> package.


Thanks. I think this looks promising.
Is the template package usable with 2e?
Alan Isaac

Dan

unread,
Oct 8, 2008, 4:12:10 PM10/8/08
to
On Oct 8, 11:29 am, Alan G Isaac <alan.is...@gmail.com> wrote:
> In HTML+CSS you can have e.g.
>
>   <div class="foo">Some text.</div>
>   <div class="bar">Other text.</div>
>
> and then use CSS to determine the
> display characteristics of div.foo
> and div.bar.
>
> This is really useful.
> Is there a LaTeX equivalent?
> If not, is there an effort to provide
> a LaTeX equivalent?

\foo{Some text.}
\bar{Other text.}

and then use a package to define
the commands \foo and \bar.

If there are things common to \foo and \bar,
formulate \foo and \bar as style changes and
put them into an environment that supplies the
common parts, perhaps named div:

\begin{div}\foo Some text.\end{div}
\begin{div}\bar Other text.\end{div}


Dan

Joseph Wrght

unread,
Oct 8, 2008, 4:15:48 PM10/8/08
to
Alan G Isaac wrote:
> Thanks. I think this looks promising.
> Is the template package usable with 2e?

As with all of the current LaTeX3 stuff, it is designed to work as
"l3in2e". You'll need to download the expl3 code as well: the releases
to CTAN in August work together, I think.
--
Joseph Wright

Alan G Isaac

unread,
Oct 9, 2008, 4:24:56 PM10/9/08
to
Joseph Wrght wrote:
> As with all of the current LaTeX3 stuff, [template] is designed to work as

> "l3in2e". You'll need to download the expl3 code as well: the releases
> to CTAN in August work together, I think.

Thanks!
Alan

Guenter Milde

unread,
Oct 10, 2008, 4:26:02 AM10/10/08
to
Alan G Isaac <alan....@gmail.com> schrieb:

> In HTML+CSS you can have e.g.

> <div class="foo">Some text.</div>
> <div class="bar">Other text.</div>

> and then use CSS to determine the
> display characteristics of div.foo
> and div.bar.

> This is really useful.
> Is there a LaTeX equivalent?

Not easily, but as (La)TeX is a programming language as well, it should be
possible to construct one (at least in principle).

You might use a combination of

* optional argument
* ifthen tests

For simplicity (and this is what I need for reStructuredText syntax
highlight), I use an inline element as example.

<span class="foo">Some text.</span>
<span class="bar">Other text.</span>

could translate to

\newcommand*{\span}[2][]{%
\ifthenelse{\equal{#1}{foo}}{\foostyle #2}{}
\ifthenelse{\equal{#1}{bar}}{\barstyle #2}{%
#2}
}

Multiple classes would require looping over the optional argument list
(e.g. with \@for ... \do { } )

Günter

Javier Bezos

unread,
Oct 11, 2008, 3:42:47 AM10/11/08
to

"Alan G Isaac" <alan....@gmail.com> escribió en el mensaje de
noticias
news:Vd5Hk.1515$yI6....@nwrddc01.gnilink.net...

> In HTML+CSS you can have e.g.
>
> <div class="foo">Some text.</div>
> <div class="bar">Other text.</div>
>
> and then use CSS to determine the
> display characteristics of div.foo
> and div.bar.
>
> This is really useful.
> Is there a LaTeX equivalent?
> If not, is there an effort to provide
> a LaTeX equivalent?

IMO, the point here is not HTML but CSS. With the latter
you can define easily different foo and bar classes depending
on the context. While you can emulate <div></div> with an
environment taking an argument, emulating the contextual
variations of CSS is a lot more difficult.

Javier
----------------------------------------------
http://www.tex-tipografia.com/lc.html

0 new messages