在时间表类别创建的时间表中添加时间跨度

在时间表类别创建的时间表中添加时间跨度

如何自动打印由计划类创建的时间表中每个事件的时间跨度。例如:

\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}

您的其他需求可以在 -macro 中定义\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}

时间添加到位置旁边。我想这没问题,除非房间不是太长(不是真正的房间,是房间名称:))

正如评论:将时间放在新行上的变体,但我没有设置正确的对齐方式。

相关内容