Page LayoutProblem with new custom List Environment

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ghodsi
Posts: 1
Joined: Tue Dec 20, 2011 11:08 pm

Problem with new custom List Environment

Post by ghodsi »

Dear All,

I would like to write a list environment that only writes the non-empty items, but with the same label that would have appeared if that item was non-empty.

This is what I have:

Code: Select all

\documentclass{book}

\newcounter{mnum}
\newenvironment{mlist}{\setcounter{mnum}{0}     % 1) 2) 3)
\begin{list}{\thechapter.\arabic{mnum})}{\usecounter{mnum}\rightmargin=6mm
    \labelwidth=7mm\labelsep=2mm\setlength{\parsep}{\parskip}
    \setlength{\listparindent}{\parindent}
    \partopsep=0cm}}{\end{list}}
    
\begin{document}
\chapter{Test}
\begin{mlist}
\item
\item second item second item second item second item second item second item second item second item second item second item 
\item third
\item
\item fifth
\item
\item
\item eight
\item
\end{mlist}
\end{document}

I would like to have a new list environment that typeset something like the following animation does:

\documentclass{book}
\begin{document}
\noindent 	I want it to automatically generate this:
\begin{description}
\itemsep=0in
\item[\normalfont 1.2)] second item second item second item second item second item second item second item second item second item second item 
item[\normalfont 1.3)] third
\item[\normalfont 1.5)] fifth
\item[\normalfont 1.8)] eight
\end{description}                                                        	          	                
\end{document}
I would appreciate your help.

--Mo Ghodsi
Last edited by localghost on Tue Dec 20, 2011 11:17 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Problem with new custom List Environment

Post by 5gon12eder »

If you don't mind to use a different name than \item and put curly braces around the items, this would be quite simple:

Code: Select all

\documentclass{article}
\usepackage{ifthen}

\newcommand{\oitem}[1]
           {\ifthenelse%
             {\equal{#1}{}}%
             {\stepcounter{enumi}}%
             {\item#1}%
           }

\begin{document}
  \begin{enumerate}
    \oitem{first}
    \oitem{}
    \oitem{}
    \oitem{fourth}
    \oitem{}
  \end{enumerate}
\end{document}
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
Post Reply