%% ******************************************************
%% * This work may be distributed and/or modified under *
%% * the conditions of the LaTeX Project Public License *
%% *     http://www.latex-project.org/lppl.txt          *
%% * either version 1.3c of this license or any later   *
%% * version.                                           *
%% ******************************************************
% \PassOptionsToPackage{quiet}{xeCJK}
% \PassOptionsToPackage{quiet, no-math}{fontspec}
\documentclass[11pt]{article}
\usepackage{geometry,pdfpages,caption,indentfirst,setspace}
\captionsetup[table]{name={\textsc{Table}},labelsep=period}
\usepackage[level]{datetime}
\usepackage{authblk,xltxtra,bigfoot,enumitem}
\usepackage{booktabs,diagbox,ragged2e,tabularx}
\renewcommand\tabularxcolumn[1]{>{\Centering}m{#1}}
\usepackage[toc]{multitoc}
\usepackage[mono=false]{libertine}
% \setstretch{1.15}
% \setCJKmainfont{Chiron Sung HK}
% [BoldFont=Chiron Sung HK Bold,
%   ItalicFont=Kaiti SC]
\usepackage{hyperref,xcolor,tikz}
\hypersetup{colorlinks,urlcolor=H6,linkcolor=H2,filecolor=filecolor,pdfstartview=FitH,pdfview=FitH,pdfcreator=XeTeX output}
\definecolor{pkgcolor}{Hsb}{103,.8,.5}
\definecolor{moducolor}{Hsb}{290,.8,.5}
\definecolor{cmdcolor}{Hsb}{188,.8,.5}
\definecolor{filecolor}{Hsb}{207,.6,.7}
\definecolor{H1}{Hsb}{349,.8,.8} % 海棠紅 (Hangzhou MTR L 1 )
\definecolor{H2}{Hsb}{23, .8,.8} % 丹桂橙 (Hangzhou Metro 2 )
\definecolor{H3}{Hsb}{48, .8,.8} % 柠檬黄 (Hangzhou Metro 3 )
\definecolor{H4}{Hsb}{103,.8,.8} % 香樟绿 (Hangzhou Metro 4 )
\definecolor{H5}{Hsb}{188,.8,.8} % 青藍色 (Hangzhou MTR L 5 )
\definecolor{H6}{Hsb}{207,.8,.8} % 海洋蓝 (Hangzhou Metro 6 )
\definecolor{H7}{Hsb}{290,.8,.8} % 浪漫紫 (Hangzhou Metro 7 )
\definecolor{W1}{HTML}{CCAD52}
\definecolor{W2}{HTML}{8FCC52}
\definecolor{W3}{HTML}{52CC70}
\definecolor{W4}{HTML}{52CCCC}
\definecolor{W5}{HTML}{5270CC}
\definecolor{W6}{HTML}{8F52CC}
\definecolor{W7}{HTML}{CC52AD}
\def\pkg#1{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}}
\def\mode#1{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}}
\def\cmd#1{\texorpdfstring{\textcolor{cmdcolor}{\textsf{#1}}}{“#1”}}
\def\datechange#1#2{%
  \noindent{\makebox[\textwidth][r]{\color{H7}\rule{1.15\textwidth}{.4pt}}}
  \noindent\makebox[0pt][r]{\makebox[-3em][r]{\small\textbf{\textcolor{H7}{#1}}}\;\;}{\sffamily Update: \ignorespaces#2}}

\title{\bfseries The \pkg{LiteTable} Template: Colorful Timetable}
\author{Xia Mingyu, \href{https://www.hdu.edu.cn}{Hangzhou Dianzi University}}
\yyyymmdddate
\date{\today}
\affil{\href{mailto:xiamyphys@gmail.com}{\ttfamily xiamyphys@gmail.com}}
\date{\today\quad Version 2.4c\thanks{%
  \url{https://github.com/xiamyphys/litetable}}}
\begin{document}
\maketitle

\vspace{-2em}
\begin{abstract}
This is the document for \pkg{LiteTable} template, which provides a beautiful design of class schedule with colorful course blocks.
\end{abstract}

\tableofcontents

\clearpage

\section{Introduction}

\subsection{The purpose of this template}
This template provides a beautiful design of class schedule with colorful course blocks.

If you meet bugs when using this template, or you have better suggestions or ideas, or you want to participate in the development of the template or other templates by me, welcome to contact via email \href{mailto:xiamyphys@gmail.com}{\ttfamily xiamyphys@gmail.com}.

Also, you can join my \textsf\LaTeX{} Template Discussion \href{https://qm.qq.com/q/OnHzbNvVAG}{QQ Group: 760570712} to communicate with me and get the insider preview edition of the template.

\subsection{Packages required}
This template is based on the template \pkg{standalone}. And it requires \pkg{tikz} package to plot some graphics, \pkg{kvoptions} and \pkg{etoolbox} packages to provide global options, \pkg{expl3}\footnote{Please use the \pkg{expl3} version after 2023/10/10 to support the e-type variants for expand: \verb|\clist_count:e|.} package to support \cmd{timelist} array, \pkg{xeCJK} package to support the \textbf{Chinese, Simplified} language and \pkg{fontawesome5} package to provide a set of beautiful icons.

\subsection{Installing \pkg{LiteTable} and loading it}
For portable version, simply download latest \verb|litetable.cls| file from \href{https://github.com/xiamyphys/LiteTable}{GitHub} or \href{https://ctan.org/pkg/litetable}{CTAN} and save it under your working directory. This way of installation is simple and convenient, but you have to manually update \verb|.cls| now and then.

However, I strongly suggest that you should use terminal/cmd to implement the commands to update all the packages (and install this package) to the latest version or switch to portable version instead
\begin{verbatim}
    sudo tlmgr update --self --all
\end{verbatim}

If you are in some areas with awful Internet environment (such as GFW), you can choose proper mirror source or use other means\footnote{Please comply with local network regulations.}. To learn more, please refer to \href{https://tex.stackexchange.com/questions/55437/how-do-i-update-my-tex-distribution}{How do I update my \textsf{\TeX} distribution?}

The template provides two options, \mode{direction} and \mode{font}. Add the modes of the options you want in the square bracket of the command \verb|\documentclass[ ]{litetable}| in \verb|.tex| file.

\subsection{Compatibility}
The test environments are macOS + Mac\TeX{} 2023 / Overleaf and they all work fine for \XeLaTeX{} compiler, Windows, Linux and Unix platforms compatibility unknown.

This template is developed on macOS platform and using the font ``Heiti SC''. If this font is not installed on your computer, please use the command \verb|\setCJKfamilyfont{zhhei}{ }| after \verb|\documentclass{litetable}| to replace ``Heiti SC'' to the font exists in your computer.

\section{Global Options of \pkg{LiteTable}}
\begin{verbatim}
  \documentclass[options]{litetable}
\end{verbatim}

\subsection{The \mode{direction} option}
This option has two modes, \mode{portrait} and \mode{landscape}, which can make the timetable displayed portrait or horizontally.

\subsection{The \mode{font} option}
This option has two modes, \mode{times} and \mode{libertinus}, which can make the font to be ``Times New Roman'' or ``Libertinus'', and the default mode is ``Times New Roman''\footnote{Please ensure that your computer has been already installed the font when using this option.}.

\section{Commands of \pkg{LiteTable}}

\subsection{The \cmd{makeframe} command}
\begin{verbatim}
  \makeframe[Sem 6]{Timetable}
\end{verbatim}

This command has two variables can create an empty class schedule. The second variable can assign the title while the first optional one can add a button that forward to the next page on the right.

\subsection{The \cmd{weeklist} command}
\begin{verbatim}
  \weeklist{
    \textcolor{W1}{Monday},    \textcolor{W2}{Tuesday},
    \textcolor{W3}{Wednesday}, \textcolor{W4}{Thursday},
    \textcolor{W5}{Friday};
    0,.17,.34,.56,.78,1
  }
\end{verbatim}


\begin{figure}[!ht]
  \centering
  \tikz
  {
    \tikzset{every node/.style={font=\small}}
    \draw [thick,->,>=stealth] ({-1/16*5.1 in},0) -- (5.1 in,0);
    \draw ({-5.1 in/16},-.1) --++ (0,.2) node [above] {\verb|-1/15|};
    \draw ({0.0*5.1 in},-.1) --++ (0,.2) node [above] {\verb|0|};
    \draw ({.17*5.1 in},-.1) --++ (0,.2) node [above] {\verb|.17|};
    \draw ({.34*5.1 in},-.1) --++ (0,.2) node [above] {\verb|.34|};
    \draw ({.56*5.1 in},-.1) --++ (0,.2) node [above] {\verb|.56|};
    \draw ({.78*5.1 in},-.1) --++ (0,.2) node [above] {\verb|.78|};
    \draw ({1.0*5.1 in},-.1) --++ (0,.2) node [above] {\verb|1|};
    \node [above] at ({.085*5.1 in},0) {\sffamily\textcolor{W1}{Monday}};
    \node [above] at ({.255*5.1 in},0) {\sffamily\textcolor{W2}{Tuesday}};
    \node [above] at ({.45*5.1 in},0) {\sffamily\textcolor{W3}{Wednesday}};
    \node [above] at ({.67*5.1 in},0) {\sffamily\textcolor{W4}{Thursday}};
    \node [above] at ({.89*5.1 in},0) {\sffamily\textcolor{W5}{Friday}};
  }
  \caption*{The second line of array in the \cmd{weeklist} command corresponds to the axis coordinates.}
\end{figure}


This command can add workdays to the top side of the timetable, you can adjust the format (the icon before it), every width of the columns in the timetable like the figure. The timetable can automatically generate the corresponding number of columns based on the number of workdays you enter. For example, the code above has 5 workdays, a 5-column timetable will be generated.

\subsection{The \cmd{timelist} command}
\begin{verbatim}
  \timelist [13] {%
    8:05,8:55,10:00,10:50,11:40,13:30,14:20,15:15,16:05,18:30,19:20,20:10;
    8:50,9:40,10:45,11:35,12:25,14:15,15:05,16:00,16:50,19:15,20:05,20:55
  }
  \timelist [13] {}
\end{verbatim}

The command \cmd{timelist} has two variables while the second one \cmd{\ttfamily\{\#2\}} can add time to the left side of the timetable, and the first line of the content is the start time of the classes while the second line of the content is the end time of the classes, each time separates with a comma (\verb|,|), the first line and the second line separates with a semicolon (\verb|;|).

The timetable can automatically generate the corresponding number of rows based on the number of time groups you enter. For example, the code above has 12 groups of times, a 12-row timetable will be generated.

The first optional variable \cmd{\ttfamily[\#1]} can directly assign the number of rows on the timetable you want without adding time to the left side of the timetable, and there will only be a series of numbers that \emph{aligned vertically to the center of every line}.

\begin{table}[!ht]
\centering
\caption{Usage of the two variables.}

\begin{tabularx}{\textwidth}{c >{\raggedright\arraybackslash}X >{\raggedright\arraybackslash}X}
  \toprule
  \diagbox{\cmd{\ttfamily[\#1]}}{\cmd{\ttfamily\{\#2\}}} & \multicolumn{1}{c}{To use}          & \multicolumn{1}{c}{Not to use}\\
  \midrule
  To use     &
  The effect is the description of \cmd{\ttfamily\{\#2\}}, but number of rows assign by \cmd{\ttfamily[\#1]} &
  The effect is the description of \cmd{\ttfamily[\#1]}\\
  \midrule
  Not to use &
  The effect is the description of \cmd{\ttfamily\{\#2\}} &
  The effect is the description of \cmd{\ttfamily[\#1]} before with \emph{default format of 12 lines}\\
  \bottomrule
\end{tabularx}
\end{table}

If you want to use the first variable \cmd{\ttfamily[\#1]} only, not to add anything in the second variable.

\begin{itemize}
  \item Assume that \cmd{\ttfamily\{\#2\}} has 12 groups of times, and \cmd{\ttfamily[\#1]} passed a value of 14, then the left side of the timetable will have only 1 -- 12 rows with time while the last two rows without time the label of them is still upward, not vertically aligned in the center.
  \item Assume that \cmd{\ttfamily\{\#2\}} has 14 sets of times, and \cmd{\ttfamily[\#1]} passes a value of 12, then only 12 rows of timetables will be generated with time on the left side of each row, that is, the last two sets of data in \cmd{\ttfamily\{\#2\}} will be invalid.
\end{itemize}

\subsection{The \cmd{weeks} command}
\begin{verbatim}
  \weeks{Week 1 -- 16}
\end{verbatim}

This command can assign the default value of the 7th variable of the command \cmd{course}.

\subsection{The \cmd{course} command}
\begin{verbatim}
  \course[H1]{8}{9}{Group Theory}{Building 6 · 211}{Li Ge}[Week 1 -- 16]
\end{verbatim}

There are 7 variables in this command.
\begin{itemize}
  \item The 1st one is the color of the class, from ``H1'' to ``H9'', it's optional and the default is ``H1''.
  \item The 2nd -- 6th ones is the starting number and ending number, name, address, teacher(s) of the class.
  \item The last one is the start week and end week of the timetable, it's optional and the default value is the value that you've adjusted in the command \cmd{weeks} or it will be ``Week 1 -- 12''.
\end{itemize}

\subsection{The \cmd{corner} command}
\begin{verbatim}
  \corner{6 pt}
\end{verbatim}

This command determines the corner radius of the course block.

\subsection{The \cmd{newday} command}
This command can switch the current weekday to the next day, then the course will move right one grid.

\subsection{The \cmd{more} command}
\begin{verbatim}
  \more{· School Start: 04 / 03 / 2024  · Summer Vacation: 05 / 07 / 2024}
\end{verbatim}

This command can add remark at the end of the class schedule.

\subsection{The \cmd{sticker} command}
\begin{verbatim}
  \sticker{favicon}
\end{verbatim}

There will be a sticker on the southeast of the page after you add, otherwise it won't.

\section{Version History}

The design of this course schedule originated from the student course schedule web page (only personnel of this school can access) of the \href{https://www.hduhelp.cn/}{HDUHelp} in \href{https://www.hdu.edu.cn}{Hangzhou Dianzi University}. The layout is very beautiful and I used \textsf{\LaTeX} to imitate that style and made a template to share with everyone.

\textsf{\bfseries Version 1.0} was finished on 2023/09/01 and released on \href{https://www.latexstudio.net}{\textsf{\LaTeX} Studio} (Hsiaoshan, Hangzhou), where has won the favor of many people.
\clearpage
\setlist[itemize]{noitemsep, topsep=0pt}
\datechange{2023/11/01}{Version 2.0a}
\begin{itemize}
    \item Supports to set the course block's corners be round or sharp.
    \item Supports to add multiply class schedules in one \verb|.tex| file.
\end{itemize}

\datechange{2023/11/05}{Version 2.1a}
\begin{itemize}
    \item Supports to use the libertinus font.
\end{itemize}

\datechange{2024/01/31}{Version 2.2a}
\begin{itemize}
    \item Fixed the bug of resolution exceeded.
    \item Changed paper type to US letter.
    \item Support to custom course start time and end time.
    \item Support to add sticker as you like at the southeast of the page.
    \item Provide simplified Chinese documentation.
\end{itemize}

\datechange{2024/02/02}{Version 2.3a}
\begin{itemize}
  \item Supports to generate the corresponding number of rows based on the number of time groups you enter automatically.
  \item Timetable can be displayed portrait or horizontally as you like.
\end{itemize}

\datechange{2024/02/03}{Version 2.3b}
\begin{itemize}
  \item Optimized coordinate calculation and improved compilation speed.
\end{itemize}

\datechange{2024/02/24}{Version 2.4a}
\begin{itemize}
  \item Supports to custom workday display style.
  \item Supports to hide time and only showing course program number vertically aligned.
  \item Supports to set default first and last week.
\end{itemize}

\datechange{2024/03/01}{Version 2.4b}
\begin{itemize}
  \item Fixed the error of \emph{resolution exceed} in the \mode{landscape} mode and added over 7 workdays.
  \item Supports to custom every width of the columns in the timetable.
  \item Optimized the design of round corners, supports custom the radius of corners.
  \item Thanks for @egreg's code solution on \TeX{} StackExchange for \href{https://tex.stackexchange.com/a/711657/299948}{Printing the number of each rows' elements in an array respectively}.
\end{itemize}

\datechange{\today}{Version 2.4c}
\begin{itemize}
  \item Supports to add the `Semester' button on the right side of the title.
\end{itemize}

\appendix
\includepdf[pages={2,4},nup=1x2,pagecommand={
  \tikz[remember picture, overlay]
  \node [rotate=90,below,yshift=-1em] at (current page.west) {\bfseries\LARGE Document Example: \texttt{litetable-demo.tex}};
  }
]{litetable-demo.pdf}
\includepdf[pages={1,3}]{litetable-demo.pdf}

\end{document}