저는 특정 요일(M, W)만 진행되는 수업의 강의 계획서를 작성하려고 합니다. 수업요일을 확인하고 날짜에 따라 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
. 세 글자로 된 각 날짜/짧은 날짜의 길이는 다릅니다.