3 天课程大纲中的提前日期

3 天课程大纲中的提前日期

我正在努力适应这种提前日期方法为期 3 天的课程大纲,但没有成功。

目标是创建一个 MWF 课程表。上面链接中的方法适用于两天的课程表。它采用当前日期的三个字母的星期几(“Mon”、“Tue”等),并将其与包含开始日期的框的宽度(例如“Mon”)进行比较。如果宽度相等,则前进两位并打印提前两天的日期。否则,前进五天。相比之下,如果当前日期是“Mon”,我需要将日期前进两天,如果当前日期是“Wed”,则前进两天,否则前进三天。

假设课程从周一开始,两天方法会将“周一”保存在一个框中,用于布尔比较以推进日期。所以我为“周三”创建了第二个框

\newsavebox{\MONDAY}\savebox{\MONDAY}{Mon}% Mon
\newsavebox{\WEDNESDAY}\savebox{\WEDNESDAY}{Wed}% WED

然后在“if”语句中添加另一个条件:

\newcommand{\class}[1]{%
  \cleardate{mydate}% Clear date
  \newdate{mydate}{\the\day}{\the\month}{\the\year}% Store date
  \section*{\displaydate{mydate} \quad #1}% Set heading
  \setbox1=\hbox{\shortdayofweekname{\getdateday{mydate}}{\getdatemonth{mydate}}{\getdateyear{mydate}}}%
  \ifdim\wd1=\wd\MONDAY
    \AdvanceDate[2]
  \else
  \ifdim\wd1=\wd\WEDNESDAY
    \AdvanceDate[2]
  \else
    \AdvanceDate[3]
  \fi%
}

但这不起作用。有什么建议吗?

完整 MWE:

\documentclass{article}
\usepackage[ddmmyyyy]{datetime}% http://ctan.org/pkg/datetime
\usepackage{advdate}% http://ctan.org/pkg/advdate

\newdateformat{syldate}{\THEMONTH/\THEDAY/\THEYEAR}%(\shortdayofweekname%{\THEDAY}{\THEMONTH}{\THEYEAR})}

\newsavebox{\MONDAY}\savebox{\MONDAY}{Mon}% Mon
\newsavebox{\WEDNESDAY}\savebox{\WEDNESDAY}{Wed}% WED

\makeatletter
\newcommand{\cleardate}[1]{%
  \expandafter\let\csname date@#1@d\endcsname\relax% Clear day
  \expandafter\let\csname date@#1@m\endcsname\relax% Clear month
  \expandafter\let\csname date@#1@y\endcsname\relax% Clear year
}
\makeatother

\newcommand{\class}[1]{%
  \cleardate{mydate}% Clear date
  \newdate{mydate}{\the\day}{\the\month}{\the\year}% Store date
  \section*{\displaydate{mydate} \quad #1}% Set heading
  \setbox1=\hbox{\shortdayofweekname{\getdateday{mydate}}{\getdatemonth{mydate}}{\getdateyear{mydate}}}%
  \ifdim\wd1=\wd\MONDAY
    \AdvanceDate[2]
  \else
  \ifdim\wd1=\wd\WEDNESDAY
    \AdvanceDate[2]
  \else
    \AdvanceDate[3]
  \fi%
}

\SetDate[14/01/2019]


\begin{document}

\class{First class}
\class{Second class}
\class{Third class}


\class{Fourth class}
\class{Fifth class}
\class{Sixth class}
\class{Seventh class}

\end{document}

答案1

一旦使用以下代码关闭外部条件,您的代码就可以正常工作\fi

在此处输入图片描述

\documentclass{article}

\usepackage[ddmmyyyy]{datetime}% http://ctan.org/pkg/datetime
\usepackage{advdate}% http://ctan.org/pkg/advdate

\newdateformat{syldate}{\THEMONTH/\THEDAY/\THEYEAR}

\newsavebox{\MONDAY}\savebox{\MONDAY}{Mon}% Monday
\newsavebox{\WEDNESDAY}\savebox{\WEDNESDAY}{Wed}% Wednesday

\makeatletter
\newcommand{\cleardate}[1]{%
  \expandafter\let\csname date@#1@d\endcsname\relax% Clear day
  \expandafter\let\csname date@#1@m\endcsname\relax% Clear month
  \expandafter\let\csname date@#1@y\endcsname\relax% Clear year
}
\makeatother

\newcommand{\class}[1]{%
  \cleardate{mydate}% Clear date
  \newdate{mydate}{\the\day}{\the\month}{\the\year}% Store date
  \section*{\displaydate{mydate} \quad #1}% Set heading
  \setbox1=\hbox{\shortdayofweekname{\getdateday{mydate}}{\getdatemonth{mydate}}{\getdateyear{mydate}}}%
  \ifdim\wd1=\wd\MONDAY
    \AdvanceDate[2]
  \else
    \ifdim\wd1=\wd\WEDNESDAY
      \AdvanceDate[2]
    \else
      \AdvanceDate[3]
    \fi
  \fi
}

\SetDate[14/01/2019]

\begin{document}

\class{First class}
\class{Second class}
\class{Third class}

\class{Fourth class}
\class{Fifth class}
\class{Sixth class}
\class{Seventh class}

\end{document}

此外,考虑迁移到datetime2自从datetime被认为过时的

相关内容