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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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