Termcal 根据上课日期在表格边框上打印上课日期

Termcal 根据上课日期在表格边框上打印上课日期

上课日越接近星期五,termcal包裹右边打印的班级号码就越多。

这里有一些图片可以解释我上面所说的内容:

周一,

在此处输入图片描述

星期五,

在此处输入图片描述

我也观察到了同样的情况,无论每周上课多少节,但每周上两节课,问题似乎只出现在第一列。例如,周四和周五的情况如下

在此处输入图片描述

每周上三节课,虽然问题仍然存在,但外观对我来说一点也不困扰。我们这里周三、周四和周五上课。

在此处输入图片描述

如何才能解决这个问题?

这是我用来生成此线程上显示的图像的代码的恢复版本。

\documentclass[a4paper,12pt]{article}

\usepackage{termcal}
\usepackage{xcolor}

% I've used this on my original file to alter the date format and color
\makeatletter
\renewcommand\monthname{
    \ifcase\c@month
        \or jan \or fev \or mar \or abr
        \or mai \or jun \or jul \or ago
        \or sep \or out \or nov \or dez
    \fi
}
\renewcommand\ordinaldate{
    \the\c@date\textsuperscript{o}
}
\renewcommand\calprintdate{
    \ifnewmonth
        \textcolor{purple}{\arabic{date}}/\arabic{month}
    \else
        \arabic{date}/\arabic{month}
    \fi
}
\makeatother

% Command for the class day corresponding to Friday
\newcommand{\Sex}{
    \skipday
    \skipday
    \skipday
    \skipday
    \calday[sex]{\classday} 
    \skipday\skipday
}

\begin{document}

\begin{center}
    \begin{calendar}{8/18/2014}{2}
        \setlength{\calboxdepth}{.3in}
        \Sex
        \caltexton{1}{Start class}
        \caltextnext{Another class}
    \end{calendar}
\end{center}

\end{document}

答案1

链接的解决方案有点儿像 hack,事实上,类中至少有三处需要%消除代码中的虚假空格。正是这些虚假空格将您的日期和类文本移到了右侧。因此,删除它们会将所有文本移到左侧,这正是类应该如何工作。您对 的重新定义中也有一个虚假空格,\printdate我也已修复了它。

删除虚假空格

首先,使用您的文档,进行以下必要的重新定义,以使课程按设计工作:

\documentclass[a4paper,12pt]{article}

\usepackage{termcal}
\usepackage{xcolor}
\makeatletter
\renewcommand\ca@doaday[1]{% Added here
\hbox{\vrule depth \calboxdepth height 0pt width 0pt\vtop{%  
   #1%                                 %options specified by |\calday|
   \csname\curdate options\endcsname%  % options specified by date
   \ifclassday\csname C\theclassnum options\endcsname\fi%   by classnumber
   \hbox to \hsize{\calprintdate\hfill\ifclassday\calprintclass\fi}%
   \vspace{2pt}
      \begingroup
        \let\\=\ca@normbs
        \raggedright
        \sloppy
        \the\weeklytext\par
        \csname\curdate text\endcsname%
        \ifclassday\csname C\theclassnum text\endcsname
                   \stepcounter{classnum}\fi
      \endgroup
   }}%
    \global\newmonthfalse
    \advancedate%
}%
\renewcommand\advancedate{\stepcounter{date}% Added here
    \ifnum\thedate>\monthlength\relax
       \addtocounter{date}{-\monthlength}\advancemonth\fi}

\renewcommand\advancemonth{%
   \global\newmonthtrue\stepcounter{month}% <-- another spurious space
   \ifnum\c@month>12
      \stepcounter{year}\setleap\setcounter{month}1\fi}

% I've used this on my original file to alter the date format and color
\makeatletter
\renewcommand\monthname{
    \ifcase\c@month
        \or jan \or fev \or mar \or abr
        \or mai \or jun \or jul \or ago
        \or sep \or out \or nov \or dez
    \fi
}
\renewcommand\ordinaldate{
    \the\c@date\textsuperscript{o}
}
\renewcommand\calprintdate{% Added here
    \ifnewmonth
        \textcolor{purple}{\arabic{date}}/\arabic{month}
    \else
        \arabic{date}/\arabic{month}
    \fi
}
\makeatother

% Command for the class day corresponding to Friday
\newcommand{\Sex}{
    \skipday
    \skipday
    \skipday
    \skipday
    \calday[sex]{\classday} 
    \skipday\skipday
}

\begin{document}

\begin{center}
    \begin{calendar}{8/18/2014}{2}
        \setlength{\calboxdepth}{.3in}
        \Sex
        \caltexton{1}{Start class}
        \caltextnext{Another class}
    \end{calendar}
\end{center}

\end{document}

第一个代码的输出

添加更多空间

如果您想要进一步缩进日期和类文本,则需要自己添加间距,既可以在 的定义中,也可以在\ca@doaday的重新定义中\printdate。为此,我创建了一个新的长度并添加了适当的长度\hspace*以插入空格。

\documentclass[a4paper,12pt]{article}

\usepackage{termcal}
\usepackage{xcolor}
\newlength{\tcalindent}
\setlength{\tcalindent}{1em}
\makeatletter
\renewcommand\ca@doaday[1]{% Added here
\hbox{\vrule depth \calboxdepth height 0pt width 0pt\vtop{%  
   #1%                                 %options specified by |\calday|
   \csname\curdate options\endcsname%  % options specified by date
   \ifclassday\csname C\theclassnum options\endcsname\fi%   by classnumber
   \hbox to \hsize{\calprintdate\hfill\ifclassday\calprintclass\fi}%
   \vspace{2pt}
      \begingroup
        \let\\=\ca@normbs
        \raggedright
        \sloppy
        \the\weeklytext\par
        \hspace*{\tcalindent}
        \csname\curdate text\endcsname%
        \ifclassday\csname C\theclassnum text\endcsname
                   \stepcounter{classnum}\fi
      \endgroup
   }}%
    \global\newmonthfalse
    \advancedate%
}%
\renewcommand\advancedate{\stepcounter{date}% Added here
    \ifnum\thedate>\monthlength\relax
       \addtocounter{date}{-\monthlength}\advancemonth\fi}

\renewcommand\advancemonth{%
   \global\newmonthtrue\stepcounter{month}% <-- another spurious space
   \ifnum\c@month>12
      \stepcounter{year}\setleap\setcounter{month}1\fi}

% I've used this on my original file to alter the date format and color

\renewcommand\monthname{
    \ifcase\c@month
        \or jan \or fev \or mar \or abr
        \or mai \or jun \or jul \or ago
        \or sep \or out \or nov \or dez
    \fi
}
\renewcommand\ordinaldate{
    \the\c@date\textsuperscript{o}
}
\renewcommand\calprintdate{% Added here
    \hspace*{\tcalindent}
    \ifnewmonth
        \textcolor{purple}{\arabic{date}}/\arabic{month}
    \else
        \arabic{date}/\arabic{month}
    \fi
}
\makeatother

% Command for the class day corresponding to Friday
\newcommand{\Sex}{
    \skipday
    \skipday
    \skipday
    \skipday
    \calday[sex]{\classday} 
    \skipday\skipday
}

\begin{document}

\begin{center}
    \begin{calendar}{8/18/2014}{2}
        \setlength{\calboxdepth}{.3in}
        \Sex
        \caltexton{1}{Start class}
        \caltextnext{Another class}
    \end{calendar}
\end{center}

\end{document}

第二个代码的输出

相关内容