我正在编辑一个生成日历的 tex 文件。它运行良好,我想在日历上的某一天添加文本。日历目前如下所示:
日历的每个单元都是用一个命令生成的:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{color}
\definecolor{WriteBgSec}{gray}{0.9}
\definecolor{Black}{gray}{0}
\begin{document}
\newlength{\DayColWidthMP}
\setlength{\DayColWidthMP}{0.25\textwidth}
\newcommand{\vstrut}[2][0pt]{\rule[#1]{0pt}{#2}}
% Cell format on Monthly Planner
% - template: #1 - color for day number and left rule, #2 - date number
\newcommand{\CellFormatMPTemplate}[2]{%
% gray bar at the top, ~ half row width
\makebox[0pt][l]{\smash[b]{\color{WriteBgSec}\rule[0.4\baselineskip]{\DayColWidthMP}{0.5\baselineskip}}}%
% thin rule to the left almost full heigh
{\color{#1}\rule[-6\baselineskip]{\arrayrulewidth}{6\baselineskip}}%
% right-aligned date numbers
\makebox[2.7ex]{\hspace{\fill}{\color{#1}#2}}%
% the column is centered so force the previous box to the left
\hspace*{\fill}%
\break%
% white last row, makes the left sided line open/incomplete (does not join the one below)
\vstrut{1em}}
% These calls are put in a tabular* to make a calendar
\CellFormatMPTemplate{Black}{2}
\end{document}
我想在日期数字下面添加节假日,例如“元旦”、“公司野餐”等。我无论如何也想不出如何将文本添加到其右侧\rule
。我找不到太多文档,但我怀疑\rule
不支持这种内联多行文本的概念?
我有什么选择?我应该做其他事情来画线吗?我可以做其他事情来在这里获得多行文本吗?
答案1
非常感谢您的反馈,@John 的提示让我走上了正确的道路。我使用 \parbox 在需要的地方添加文本。完成后的样子:
% Cell format on Monthly Planner
% - template: #1 - color for day number and left rule, #2 - date number, #3 - event text to show on date
\newcommand{\CellFormatMPTemplate}[3]{%
% gray bar at the top, ~ half row height
\makebox[0pt][l]{\smash[b]{\color{WriteBgSec}\rule[0.4\baselineskip]{\DayColWidthMP}{0.5\baselineskip}}}%
% thin rule to the left almost full heigh
{\color{#1}\rule[-6\baselineskip]{\arrayrulewidth}{6\baselineskip}}%
% date numbers and event text
\hspace{1ex}\parbox[t]{\DayColWidthMP-1.5ex}{\color{#1}\makebox[1.7ex][r]{#2}\\\scriptsize#3}%
% white last row, makes the left sided line open/incomplete (does not join the one below)
\vstrut{1em}}