1

I need to modify enumeration list environment, but just in one place and not globally, for tex4ht.

I have reason where this one particular enumeration list, I need it not to wrap. i.e. each \item should not wrap.

I figured how to do it, but globally. i.e. now all my enumeration lists are affected which is not what I want. Here is an example how to change it globally

\documentclass[12pt,notitlepage]{article}
\begin{document} 
\ifdefined\HCode
\Css{body{
      margin:  0 auto;  /* center */
      outline: 1px solid \#D3D3D3;
      max-width:500px;
      }}
\fi 

\begin{enumerate}
\item some long text here, some long text here, some long text here, some long text here, some long text here, some long text here
\item some long text here
\end{enumerate}

\end{document}

Then created this my.cfg file

\Preamble{xhtml,p-width}
\ConfigureEnv{enumerate}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="nowaprEnumerate">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{}
{}

\Css{.nowaprEnumerate {white-space: nowrap;}}
\begin{document}

\EndPreamble

And now I compile using

 make4ht -ulm default -a debug -c my.cfg main.tex "mathjax,htm,nostyle"

It gives

enter image description here

Which is exactly what I want. But as I said, this affects now every enumeration list I have in my document. I do not know how to make it affect specific enumeration list and not another.

I thought I need to make new environment. So I changed the above code to the following

\documentclass[12pt,notitlepage]{article}
\begin{document} 
\ifdefined\HCode
\Css{body{
      margin:  0 auto;  /* center */
      outline: 1px solid \#D3D3D3;
      max-width:500px;
      }}
\fi 

%I only want this enumeration to not wrap
\ifdefined\HCode 
\begin{nowaprEnumerate}
\else 
\begin{enumerate}
\fi 
\item some long text here, some long text here, some long text here, some long text here, some long text here, some long text here
\item some long text here
\ifdefined\HCode 
\end{nowaprEnumerate}
\else 
\end{enumerate}

\end{document}

And changed .cfg to the following

\Preamble{xhtml,p-width}
\ConfigureEnv{nowaprEnumerate} %CHANGED THIS LINE
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="nowaprEnumerate">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{}
{}

\Css{.nowaprEnumerate {white-space: nowrap;}}
\begin{document}

\EndPreamble

When compiling again, tex4ht gives error

 LaTeX Error: Environment nowaprEnumerate undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.60 \begin{nowaprEnumerate}

I understand the error. There is no nowaprEnumerate.

But I have no idea what to do now. I think I need some other trick to modify enumeration environment as above, but at same time, give it a new name, and use this new name where in the document I need to modify the enumeration and not use when I want the normal enumeration.

But do not know how to do this.

Any suggestions how do the above? i.e. change enumeration list environment, just for tex4ht in specific places? clearly I need new environment for tex4ht to do this.

TL 2023

1 Answer 1

1

You just need to declare your nowrapEnumerate using \newenvironment. As it is unknown to LaTeX, you will get an error otherwise. This way, you also remove the necessity for conditionals in your document.

Your document can look like this:

\documentclass[12pt,notitlepage]{article}
\newenvironment{nowaprEnumerate}{\begin{enumerate}}{\end{enumerate}}
\begin{document} 
%I only want this enumeration to not wrap
\begin{nowaprEnumerate}
\item some long text here, some long text here, some long text here, some long text here, some long text here, some long text here
\item some long text here
\end{nowaprEnumerate}

\end{document}

And this is the config file:

\Preamble{xhtml,p-width}
\ConfigureEnv{nowaprEnumerate} %CHANGED THIS LINE
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="nowaprEnumerate">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
{}
{}


\Css{.nowaprEnumerate {white-space: nowrap;}}

\Css{body{
      margin:  0 auto;  /* center */
      outline: 1px solid \#D3D3D3;
      max-width:500px;
      }}

\begin{document}

\EndPreamble

The result:

enter image description here

1
  • Yes, thanks. This is better. I remember sort of I needed to make new environment but forgot how and did not find an example. I need to add this to my cheat sheet as it seems very useful. Once I started using max-width=640px for my web pages (so that lines are not too long for reading), I am finding that I needed to modify some environments now to make them look better with the new layout and this was one case where I needed to do this.
    – Nasser
    Commented Oct 1, 2023 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .