4

I have the following custom list for generating dates on a syllabus:

\documentclass{article}
\usepackage{advdate}
\usepackage[dayofweek]{datetime}
\newdateformat{syldate}{\twodigit{\THEMONTH}/\twodigit{\THEDAY}
\,(\shortdayofweekname
{\THEDAY}{\THEMONTH}{\THEYEAR})}
\newenvironment{schedule}
  {\par\syldate\renewcommand{\item}{\par
    \stepcounter{mycntr}\ifnum\value{mycntr}>2\relax
      \setcounter{mycntr}{0}\AdvanceDate[3]
    \else
      \AdvanceDate[2]
    \fi\today\quad}
  }{\par}
\SetDate[01/09/2014]
\newcounter{mycntr}

\begin{document}

\begin{schedule} % My custom environment with problematic behavior

\item Topic \\ Assigned Reading

\item Topic \\ Assigned Reading

\end{schedule}

\begin{itemize} % Desired behavior
    \item Topic \\ Assigned Reading
    \item Topic \\ Assigned Reading
\end{itemize}

\end{document}

Whenever I try to move the second part of an item to a new line, it aligns itself with the item label rather than the first line of the item. Itemize does what I want by default. How do I build that behavior into my custom list?

3

If you don't plan to have lists and paragraphs in the “Assigned readings”, you can go with

\documentclass{article}
\usepackage{advdate}
\usepackage[dayofweek]{datetime}
\newdateformat{syldate}{%
  \twodigit{\THEMONTH}/\twodigit{\THEDAY}%
  \,(\shortdayofweekname
  {\THEDAY}{\THEMONTH}{\THEYEAR})%
}
\newlength{\datelength}
\newenvironment{schedule}
  {\par
   \settowidth{\datelength}{00/00\,(Wed)\quad}%
   \renewcommand{\item}{%
     \par\hangindent=\datelength\noindent
     \stepcounter{mycntr}\ifnum\value{mycntr}>2\relax
       \setcounter{mycntr}{0}\AdvanceDate[3]%
    \else
       \AdvanceDate[2]%
    \fi
    \makebox[\datelength][l]{\today}%
  }%
  \syldate
  }
  {\par}
\SetDate[01/09/2014]
\newcounter{mycntr}

\begin{document}

\begin{schedule} % My custom environment with problematic behavior

\item Topic \\ Assigned Reading

\item Topic \\ Assigned Reading

\item Topic \\ Assigned Reading

\item Topic \\ Assigned Reading

\end{schedule}

\end{document}

enter image description here

However, a better implementation is with enumitem:

\documentclass{article}
\usepackage{showframe} % just for the example
\usepackage{enumitem}
\usepackage{advdate}
\usepackage[dayofweek]{datetime}
\newdateformat{syldate}{%
  \twodigit{\THEMONTH}/\twodigit{\THEDAY}%
  \,(\shortdayofweekname
  {\THEDAY}{\THEMONTH}{\THEYEAR})%
}
\newlength{\datelength}
\newcommand\topic[1]{%
  \stepcounter{mycntr}%
  \ifnum\value{mycntr}>2\relax
    \setcounter{mycntr}{0}\AdvanceDate[3]%
  \else
    \AdvanceDate[2]%
  \fi
  \item[\today]#1\\
}
\newenvironment{schedule}
  {\syldate
   \settowidth{\datelength}{00/00\,(Wed)\quad}%
   \enumerate[leftmargin=\datelength,labelsep=0pt,labelwidth=\datelength,align=left]
  }
  {\endenumerate}
\SetDate[01/09/2014]
\newcounter{mycntr}

\begin{document}

\begin{schedule}

\topic{Topic} Assigned Reading

\topic{Topic} Assigned Reading

\topic{Topic} Assigned Reading

\topic{Topic} Assigned Reading

\end{schedule}

\end{document}

I'd prefer a \topic command instead of abusing \item so that the appearance of the topic title can be customized at will by just acting on the definition of \topic.

Vertical spacings can be customized with enumitem features. Note that showframe is used here just to show the text block margins.

enter image description here

1

The disparity of indent arises from the fact that the 1st line indent is due to \parindent, which does not carry to successive lines. The parameter for carrying an indent to successive lines is \leftskip. I would significantly rewrite the approach (perhaps using a list environment, but to quickly achieve what you ask, I merely inserted this line

\leftskip=\parindent\relax\parindent=0pt\relax

at the beginning of your schedule environment. It has the effect of using the current value of \parindent for the \leftskip for that invocation of the environment.

\documentclass{article}
\usepackage{advdate}
\usepackage[dayofweek]{datetime}
\newdateformat{syldate}{\twodigit{\THEMONTH}/\twodigit{\THEDAY}
\,(\shortdayofweekname
{\THEDAY}{\THEMONTH}{\THEYEAR})}
\newenvironment{schedule}
  {\leftskip=\parindent\relax\parindent=0pt\relax
    \par\syldate\renewcommand{\item}{\par
    \stepcounter{mycntr}\ifnum\value{mycntr}>2\relax
      \setcounter{mycntr}{0}\AdvanceDate[3]
    \else
      \AdvanceDate[2]
    \fi\today\quad}
  }{\par}
\SetDate[01/09/2014]
\newcounter{mycntr}

\begin{document}

\begin{schedule} % My custom environment with problematic behavior

\item Topic \\ Assigned Reading

\item Topic \\ Assigned Reading

\end{schedule}

\begin{itemize} % Desired behavior
    \item Topic \\ Assigned Reading
    \item Topic \\ Assigned Reading
\end{itemize}

\end{document}

Note that the way you have set things, the schedule environment is indented by a value of \parindent. That can be removed by setting, in my MWE, the value of \leftskip to 0pt, rather than to \parindent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.