Discussion:
[Docutils-develop] [docutils:patches] #99 latex2e: Handle classes for bullet & field lists
Günter Milde
2017-02-08 16:49:39 UTC
Permalink
I don't like the idea of local commands/environments just for class handling.
Instead, I propose wrapping elements in a group or environment if there are class arguments present. Standard environments could then be easily redefined in preamble, stylesheet, or raw latex code
- see attached patch and examples.


Attachments:

- [class-wrapper-test.tex](https://sourceforge.net/p/docutils/patches/_discuss/thread/23ac30c5/be1e/attachment/class-wrapper-test.tex) (6.7 kB; text/x-tex)


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** open
**Group:**
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Fri Aug 15, 2014 01:39 AM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Günter Milde
2017-02-08 16:51:46 UTC
Permalink
Example document: rST source


Attachments:

- [class-wrapper-test.txt](https://sourceforge.net/p/docutils/patches/_discuss/thread/23ac30c5/764b/attachment/class-wrapper-test.txt) (3.5 kB; text/plain)


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** open
**Group:**
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Wed Feb 08, 2017 04:49 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Günter Milde
2017-02-08 16:54:37 UTC
Permalink
Generated LaTeX source (make sure to specify the required package(s), especially enumitem when generating from the above rST).


Attachments:

- [class-wrapper-test.tex](https://sourceforge.net/p/docutils/patches/_discuss/thread/23ac30c5/f926/attachment/class-wrapper-test.tex) (6.7 kB; text/x-tex)


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** open
**Group:**
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Wed Feb 08, 2017 04:51 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Günter Milde
2017-02-08 20:53:43 UTC
Permalink
The alternative suggestion uses class declarations or class environments in a wrapper
\begin{DUclass} \end{DUclass} environment.

+1 simpler definition of post-element code (end part of environment)

-\newcommand*{\DUCLASSrulebelow}{%
- \let\OrigItemize\itemize
- \renewenvironment{itemize}{\begin{OrigItemize}}%
- {\end{OrigItemize}\noindent
- \rule[0.5ex]{1\columnwidth}{1pt}}%
-}
+\newenvironment{DUCLASSrulebelow}{}{\noindent
+ \rule[0.5ex]{1\columnwidth}{1pt}}

+1 clear begin/end of wrapper in the .tex source

-}% end class wrapper
+\end{DUenv}

-1 more and more complicated boilerplate code

+% class handling environment (wrapper for block-level elements)
+% \begin{DUENV}{spam} tries \DUENVspam and \end{DUENVspam} tries \endDUENVspam
+\newenvironment{DUenv}[1]%
+ {\def\DUxenvxname{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DUxenvxname\endcsname}%
+ {\csname end\DUxenvxname \endcsname}%


-1 more nesting (one nesting level per class argument

-{ \DUclass{compact} \DUclass{enumerateitems}%
+\begin{DUenv}{compact}%
+\begin{DUenv}{enumerateitems}%
\begin{itemize}
...
-}% end class wrapper
+\end{DUenv}
+\end{DUenv}


Attachments:

- [class-wrapper-env-test.tex](https://sourceforge.net/p/docutils/patches/_discuss/thread/23ac30c5/f2f7/attachment/class-wrapper-env-test.tex) (6.8 kB; text/x-tex)


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** open
**Group:**
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Wed Feb 08, 2017 04:54 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Matej Cepl
2017-02-10 11:16:07 UTC
Permalink
Yes, it [builds](https://koji.fedoraproject.org/koji/taskinfo?taskID=17708646) (with its testsuite switched on) for Fedora. Thank you.


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** open
**Group:**
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Wed Feb 08, 2017 08:53 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Günter Milde
2017-05-04 18:24:09 UTC
Permalink
- **status**: open --> closed-fixed
- **Group**: --> None
- **Comment**:

The "class wrapper" for environments (block-level elements) is not in the SVN repo.



---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** closed-fixed
**Group:** None
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Wed Feb 08, 2017 08:53 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Kirill Smelkov
2017-05-05 08:15:07 UTC
Permalink
GÃŒnter thanks for getting this topic eventualy merged even if via different approach.


---

** [patches:#99] latex2e: Handle classes for bullet & field lists**

**Status:** closed-fixed
**Group:** None
**Created:** Thu Nov 15, 2012 03:22 PM UTC by Kirill Smelkov
**Last Updated:** Thu May 04, 2017 06:24 PM UTC
**Owner:** nobody


latex2e: Handle classes for bullet lists

For example authors could customize documents as follows:

.. class:: compact

\- item 1
\- item 2
\- item 3

and expect the writer to apply the class. This works for html writer,
but not yet for latex2e/xetex and that's why this patch is here.

Usual rules for customizing rendering for classed elements is done - for
class \`compact\`, if stylesheet provides an environment named
DUitemizecompact, it will be used, otherwise the default itemize.

Personally, for compact lists I use

\newenvironment\{DUitemizecompact\}\{%
\begingroup%
\small%
\begin\{itemize\}%
\itemsep=0pt\parskip=0pt%
\}\{%
\end\{itemize\}%
\endgroup%
\}

which make text a bit smaller and tightens inter-line gaps.

NOTES:

\* There is no \provideenvironment in LaTeX, so plain \newenviroment is used.
\* The implementation of DUitemize environment is a bit cumbersome.
That's because it is not possible to pass arguments to
end<something> when defining environments and because my TeX foo is
probably not high enough. \(help appreciated\)
\* I've patched the code to emit \begin\{DUitemize\} only when classes
attrubute is present - only to minimize changes to tests, for the
patch not being huge with low signal/noise ratio.



---

Sent from sourceforge.net because docutils-***@lists.sourceforge.net is subscribed to https://sourceforge.net/p/docutils/patches/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
Loading...