
如何自動列印時間表類別建立的時間表中每個事件的時間跨度。舉個例子:
\documentclass{article}
\usepackage{schedule}
\begin{document}
\CellHeight{.4in}
\CellWidth{1in}
\TimeRange{12:00-15:00}
\SubUnits{30}
\BeginOn{Monday}
\TextSize{\tiny}
\FiveDay
\TwentyFourHour
\NewAppointment{meeting}{red}{white}
\NewAppointment{workshop}{green}{blue}
\begin{schedule}[Fall Quarter, 2020]
\class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
\class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
\class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
\meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
\workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
\class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
\end{schedule}
\end{document}
現在我想在對應約會儲存格的底部列印時間跨度,而無需手動重新輸入。例如,對於“辦公時間”,應列印“14:00 - 14:50”。我怎樣才能做到這一點?
理想情況下,以下內容也應該有效:
- 為時間跨度指定(全域)單獨的字體大小
- 指定儲存格底部左對齊、居中對齊或右對齊
- 全域指定是否列印預設值
- 添加一個可選參數以在本地覆蓋此全域設置
答案1
一個快速但骯髒的解決方案是定義一個新的巨集event
來將時間參數轉發到約會標題:
\newcommand{\event}[5]{%
#1{#2\newline #5}{#3}{#4}{#5}%
}
只需將此巨集放在您的約會參數前面即可。
\event
第一個參數是約會的巨集名稱,接下來的 4 個參數將轉送到原始約會巨集。
第五個參數(時間)也用於擴展約會標題。
作為完整的範例:
\documentclass{article}
\usepackage{schedule}
\begin{document}
\CellHeight{.4in}
\CellWidth{1in}
\TimeRange{12:00-15:00}
\SubUnits{30}
\BeginOn{Monday}
\TextSize{\tiny}
\FiveDay
\TwentyFourHour
\NewAppointment{meeting}{red}{white}
\NewAppointment{workshop}{green}{blue}
\newcommand{\event}[5]{%
#1{#2\newline #5}{#3}{#4}{#5}%
}
\begin{schedule}[Fall Quarter, 2020]
\event{\class}{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
\event\class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
\event\class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
\event\meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
\event\workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
\event\class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
\end{schedule}
\end{document}
您的其他需求可以在-巨集內定義\event
。例如:
\newcommand{\event}[5]{%
#1{#2\newline\large #5}{#3}{#4}{#5}%
}
另一個版本,沒有新的宏,但對現有程式碼進行了修改:
\documentclass{article}
\usepackage{schedule}
\makeatletter
\def\draw@appt@box{%
\ifweekends \relax % if we use 7-days, this won't change
\else \ifx \the@day\skipday@i \@includefalse \fi % first condition for change
\ifx \the@day\skipday@ii \@includefalse \fi\fi % second condition for change
\ifinrange \relax\else \@includefalse \fi %
\if@include %
\put(\value{xcoords},\value{ycoords}){\colorbox{\appt@color}{\parbox[t]{\cell@width}{\ %
\vspace{\box@depth}}}}
\thinlines
\put(\value{xcoords},\value{ycoords}){\line(1,0){\value{pu@cell@width}}}
\put(\value{xcoords},\value{ycoords@bot}){\line(1,0){\value{pu@cell@width}}}
\put(\value{xcoords},\value{ycoords}){%
\ \parbox[t]{\cell@width-8pt}{\mbox{}\\ \appt@textsize %
\ifdim\box@depth>\baselineskip
\textcolor{\appt@textcolor}{\csname \appt@name @name\endcsname} \\ %
\ifdim\box@depth>2\baselineskip
\textcolor{\appt@textcolor}{\csname \appt@name
%%%%%%%%%%%Modifications
% @location\endcsname}\fi\fi }}\fi} %Original code
@location\endcsname%
\hfill \textit{\csname \appt@name @time\endcsname}%
%%\newline \csname \appt@name @time\endcsname%
}\fi\fi}}\fi}
%%%%%%%%%%%Modifications end
\makeatother
\begin{document}
\CellHeight{.4in}
\CellWidth{1in}
\TimeRange{12:00-15:00}
\SubUnits{30}
\BeginOn{Monday}
\TextSize{\tiny}
\FiveDay
\TwentyFourHour
\NewAppointment{meeting}{red}{white}
\NewAppointment{workshop}{green}{blue}
\begin{schedule}[Fall Quarter, 2020]
\class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
\class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
\class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
\meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
\workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
\class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
\end{schedule}
\end{document}
時間會加到位置旁邊。我想這還可以,除非房間不太長(不是真正的房間,房間名稱:))
作為評論:將時間放在新行上的變體,但我沒有設定正確的對齊方式。