
特定の曜日(月、水)のみに開講されるクラスのシラバスを作成しようとしています。クラスの日をチェックし、日に応じて 2 日または 5 日進めたいのですが、次のコードは機能しないようです(ステートメントで失敗します\ifthenelse
)
\documentclass{article}
\usepackage{advdate}
\usepackage[ddmmyyyy]{datetime}
\usepackage{tikz}
\newdateformat{syldate}{\THEMONTH/\THEDAY%(\shortdayofweekname%{\THEDAY}{\THEMONTH}{\THEYEAR})}
\newcommand{\class}[1]{
\def \currday {\shortdayofweekname{\the\day}{\the\month}{\the\year}}
\ifthenelse{\equal{\currday}{Mon}}{\AdvanceDate[2]}{\AdvanceDate[5]}
\section* {\syldate{\today} \quad #1}
}
\SetDate[06/01/2014]
\begin{document}
\class{First Class}
\class{Second class}
\class{Class after holiday}
\end{document}
私がこのようにしたい理由は、\today
休日のリストに含まれているかどうかを確認し、含まれている場合は自動的に次の授業日に進みたいからです。これを行う方法についてアドバイスはありますか? より効率的なコードも歓迎します。
答え1
うまくいけば、これがあなたが求めているものです:
\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
\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
\AdvanceDate[5]
\fi%
}
\SetDate[06/01/2014]
\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}
プロセスは、日付を保存してmydate
、datetime
そしてadvdate
曜日との比較は、単語の幅をテストすることによって行われますMon
。3 文字/短い日付ごとに長さが異なります。