Recently I got a page a day for math Puzzles. I was wondering if there is a LaTeX Template out there. I am trying to learn new Language and for that I thought to create page a day calender. Any help in this matter would be greatly appreciated.
2 Answers
The following example creates a Page-a-Day calendar with the corresponding entries read from an ASCII text file (actually CSV). The construction of the CSV file uses standard Excel or OpenOffice techniques, while the datatool
package provides reading and manipulating of record entries.
page-calendar.csv
"DayNum","Date","Year","MonthNum","Month","Mnth","Day","WeekdayNum","Weekday","Wkday","Saying"
1,2012-01-01,2012,1,"January","Jan",1,1,"Sunday","Sun","Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris."
2,2012-02-13,2012,2,"February","Feb",13,2,"Monday","Mon","Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque."
3,2012-03-02,2012,3,"March","Mar",2,6,"Friday","Fri","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem."
4,2012-04-19,2012,4,"April","Apr",19,5,"Thursday","Thu","Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc."
5,2012-05-23,2012,5,"May","May",23,4,"Wednesday","Wed","Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla."
6,2012-06-07,2012,6,"June","Jun",7,5,"Thursday","Thu","Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum."
7,2012-07-30,2012,7,"July","Jul",30,2,"Monday","Mon","Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus."
8,2012-08-22,2012,8,"August","Aug",22,4,"Wednesday","Wed","Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa."
9,2012-09-18,2012,9,"September","Sep",18,3,"Tuesday","Tue","Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna."
10,2012-10-06,2012,10,"October","Oct",6,7,"Saturday","Sat","Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero."
11,2012-11-20,2012,11,"November","Nov",20,3,"Tuesday","Tue","Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac quam."
12,2012-12-31,2012,12,"December","Dec",31,2,"Monday","Mon","Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum."
This file contains all the data to be used to create your page-a-day calendar. I've created a number of fields:
DayNum
: Number of the current entryDate
: Entry dateYear
: Year of entry (Excel/OpenOffice formula:=YEAR(<Date>)
)MonthNum
: Month (number) 1..12 of entry (Excel/OpenOffice formula:=MONTH(<Date>)
)Month
: Month (name) of entry (Excel/OpenOfficeVLOOKUP
using<MonthNum>
)Mnth
: Abbreviated month (name) of entry (Excel/OpenOfficeVLOOKUP
using<MonthNum>
)Day
: Day 1..31 of entry (Excel/OpenOffice formula:=DAY(<Date>)
)WeekdayNum
: Weekday number 1..7 of entry (Excel/OpenOffice formula:=WEEKDAY(<Date>)
)Weekday
: Weekday name of entry (Excel/OpenOfficeVLOOKUP
using<WeekdayNum>
)Wkday
: Abbreviated weekday (name) of entry (Excel/OpenOfficeVLOOKUP
using<WeekdayNum>
)Saying
: Saying for that specific entry
page-calendar.tex
\documentclass[12pt]{article}
\usepackage[margin=2cm,landscape,a5paper]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tikz}% http://ctan.org/pkg/pgf
\usetikzlibrary{calc}%
\usepackage{datatool}% http://ctan.org/pkg/datatool
\DTLloaddb{calendar}{page-calendar.csv}% Load page-calendar.csv into calendar DB
\pagestyle{empty}% Remove page headers/footers
\begin{document}
\sffamily% Default font family
\DTLforeach{calendar}
{\calDayNum=DayNum,
\calDate=Date,
\calYear=Year,
\calMonthNum=MonthNum,
\calMonth=Month,
\calMnth=Mnth,
\calDay=Day,
\calWeekdayNum=WeekdayNum,
\calWeekday=Weekday,
\calWkday=Wkday,
\calSaying=Saying}
{%
\begin{tikzpicture}[remember picture,overlay]
\fill[black!80!green!25]
(current page.north east) rectangle (current page.south west);% Outer frame
\shade [bottom color=black!70!green!25, top color=black!70!green!10]
($(current page.north east)+(-5mm,-5mm)$) rectangle ($(current page.south west)+(5mm,5mm)$); % Inner frame + shading
\draw ($(current page.north west)+(5mm,-5mm)$)
node[anchor=north west] {\scalebox{5}{\bfseries\color{black!65}\calYear}};% Print YEAR
\draw ($(current page.north east)+(-5mm,-5mm)$)
node[anchor=north east] {\scalebox{3}{\bfseries\color{black!80}%
\begin{minipage}{.5\linewidth}\raggedleft%
\calWeekday \par% Print WEEKDAY
\calDay~\calMonth% Print DAY + MONTH
\end{minipage}}};
\draw (current page.center)
node {\scalebox{2}{\color{black!95!green}%
\begin{minipage}{.5\linewidth}
\centering\large\calSaying% Print SAYING
\end{minipage}}};
\end{tikzpicture}%
\newpage%
}
\end{document}
Here I've just played around with tikz
to position the extracted elements on the page. I've only used Year
, Month
, Day
, Weekday
and Saying
, although all are accessible via macros. The macros are defined as part of the \DBLforeach
command. Specifically, Year
is references via the macro \calYear
, Month
via the macro \calMonth
, ... Saying
via the macro \calSaying
. Of course, you can rename these, and use a different layout and colour scheme or whatever (including the choice of page dimensions specified using geometry
).
The output
Why this way? Well, perhaps you don't want to create an entire annual calendar, but just a monthly one. Instead of fixing the construction within LaTeX, you can now manipulate it on a case-by-case basis outside and only export the entries you're interested in.
The approach is flexible enough since datatool
allows any recognizable LaTeX content to be included in the database. So, for example, if you don't want to include a saying, you could replace it with an image by merely using
\includegraphics[<options>]{<filename>}
and datatool
will place the image on the corresponding calendar day.
-
Werner, CSV file does not support Devanagari text ( i.e. अस्मिन् सांप्रतम्) is there a way to pass this to your program. I tried changing .CSV to .xls but it did not work.– AkuJan 5, 2012 at 18:24
-
@Aku: The
datatool
documentation mentions "Databases can be created using LaTeX commands or loaded from external ASCII files, such as comma or tab separated variable files." So, reading Devanagari text from an ASCII file is not possible..xls
is an encoded format and would not work. Perhaps create it from within LaTeX? I'm not familiar with using different fonts, nor do I have any of those installed on my system. You may tryexceltex
. Regardless, since I'm font-less, I can't help.– Werner ♦Jan 5, 2012 at 20:42
I don't know of any pre-built packages or classes that do it, but perhaps this will code is along the lines of what you want.
I have used the nth
package to get the correct formatting for 1st
, 2nd
, 3rd
, etc.
The main part of the code is a pretty simple loop that goes from 1 to 366 (because 2012 is a leap year). All you have to do is specify the quotes you want, and it will work. Of course, you'll probably want to jazz-up the style a bit, perhaps add some colour, but I'll leave that up to you.
\documentclass{article}
\usepackage[paperheight=4in,paperwidth=4in]{geometry}
\usepackage{ifthen}
\usepackage{forloop}
\usepackage{nth} % for 1st, 2nd, 3rd automagically!
% set counters for day and month
\newcounter{daycount}
\newcounter{monthcount}
\setcounter{daycount}{0}
\setcounter{monthcount}{1}
\newcounter{yearcount}
\setcounter{yearcount}{2012}
\newcounter{dispdaycount} % for Mon, Tue, etc
\setcounter{dispdaycount}{6} % 2012 started on Sunday, the loop increments this by 1
\newcounter{masterDayCount} % used in the main loop from 1 to 365 (or 366 in a leap year!)
% setup words for the days of the week
\newcommand{\displayday}[1]{%
\ifthenelse{\equal{#1}{1}}{Mon}{}%
\ifthenelse{\equal{#1}{2}}{Tue}{}%
\ifthenelse{\equal{#1}{3}}{Wed}{}%
\ifthenelse{\equal{#1}{4}}{Thu}{}%
\ifthenelse{\equal{#1}{5}}{Fri}{}%
\ifthenelse{\equal{#1}{6}}{Sat}{}%
\ifthenelse{\equal{#1}{7}}{Sun}{}%
}
% setup words for the months of the year
\newcommand{\displaymonth}[1]{%
\ifthenelse{\equal{#1}{1}}{Jan}{}%
\ifthenelse{\equal{#1}{2}}{Feb}{}%
\ifthenelse{\equal{#1}{3}}{Mar}{}%
\ifthenelse{\equal{#1}{4}}{Apr}{}%
\ifthenelse{\equal{#1}{5}}{May}{}%
\ifthenelse{\equal{#1}{6}}{Jun}{}%
\ifthenelse{\equal{#1}{7}}{Jul}{}%
\ifthenelse{\equal{#1}{8}}{Aug}{}%
\ifthenelse{\equal{#1}{9}}{Sep}{}%
\ifthenelse{\equal{#1}{10}}{Oct}{}%
\ifthenelse{\equal{#1}{11}}{Nov}{}%
\ifthenelse{\equal{#1}{12}}{Dec}{}%
}
% check the date to make sure the day is not above the allowed range e.g, there are only 31 days in Jan, not more
% to be used as \checkdate{daycount}{monthcount}
\newcommand{\checkdate}[2]{%
\ifthenelse{#2=2}
{%
% February only has 28 days (or 29 in a leap year like 2012)
\ifthenelse{#1>29}
{%
\addtocounter{daycount}{-29}%
\addtocounter{monthcount}{1}%
}%
{}%
}%
{}%
\ifthenelse{#2=4 \or #2=6 \or #2=9 \or #2=11}
{%
% 30 day months, April, May, September, November
\ifthenelse{#1>30}
{%
\addtocounter{daycount}{-30}%
\addtocounter{monthcount}{1}%
}%
{}%
}%
{}%
\ifthenelse{#2=1 \or #2=3 \or #2=5 \or #2=7 \or #2=8 \or #2=10 \or #2=12}
{%
% 31 day months
\ifthenelse{#1>31}
{%
\ifthenelse{#2=12}
{%
% if we're in December and the count is above 31, we need to set the month back to Jan
\addtocounter{monthcount}{-12}
}%
{}%
\addtocounter{daycount}{-31}%
\addtocounter{monthcount}{1}%
}
{}
}%
{}%
}
% worthy quotes
\newcommand{\worthyQuote}[1]{%
\ifthenelse{\equal{#1}{1}}{All we are\ldots}{}%
\ifthenelse{\equal{#1}{2}}{\dots is dust in the wind dude \ldots}{}%
\ifthenelse{\equal{#1}{3}}{dust}{}%
\ifthenelse{\equal{#1}{4}}{wind}{}%
\ifthenelse{\equal{#1}{5}}{dude!}{}%
\ifthenelse{\equal{#1}{6}}{Quote 6}{}%
\ifthenelse{\equal{#1}{7}}{Quote 7}{}%
\ifthenelse{\equal{#1}{8}}{Quote 8}{}%
\ifthenelse{\equal{#1}{9}}{Quote 9}{}%
\ifthenelse{\equal{#1}{10}}{Quote 10}{}%
\ifthenelse{\equal{#1}{11}}{Quote 11}{}%
\ifthenelse{\equal{#1}{12}}{Quote 12}{}%
\ifthenelse{\equal{#1}{13}}{Quote 13}{}%
\ifthenelse{\equal{#1}{14}}{Quote 14}{}%
\ifthenelse{\equal{#1}{15}}{Quote 15}{}%
\ifthenelse{\equal{#1}{16}}{Quote 16}{}%
\ifthenelse{\equal{#1}{17}}{Quote 17}{}%
\ifthenelse{\equal{#1}{18}}{Quote 18}{}%
\ifthenelse{\equal{#1}{19}}{Quote 19}{}%
\ifthenelse{\equal{#1}{20}}{Quote 20}{}%
\ifthenelse{\equal{#1}{21}}{Quote 21}{}%
\ifthenelse{\equal{#1}{22}}{Quote 22}{}% finish these yourself!
}
\begin{document}
\pagestyle{empty}
\forloop{masterDayCount}{1}{\value{masterDayCount} < 367}
{%
% new page for a new day
\clearpage%
% up the day counters
\addtocounter{daycount}{1}%
\addtocounter{dispdaycount}{1}%
% check that the displayed day counter doesn't go above 7
\ifthenelse{\thedispdaycount>7}{\setcounter{dispdaycount}{1}}{}%
% check the daycount for the relevant month
\checkdate{\thedaycount}{\themonthcount}%
% change this to suit your own style
\begin{flushright}
{\huge\displayday{\thedispdaycount} \nth{\thedaycount} \displaymonth{\themonthcount} \theyearcount}\\
{\textit{\worthyQuote{\themasterDayCount}}}
\end{flushright}
}
\end{document}
-
\newcommand{\daypage}[6] { \marginpar{\includegraphics[height=3.4in,width=3.4in,keepaspectratio]{imgs/#1.pdf}} \begin{center} \Large{#2} \ \HUGE{\textbf{#3}} \ \large{#4} \vspace{0.4in} \small{#5} \vspace{0.2in} \scriptsize{\textit{#6}} \end{center} \newpage } in the links posted under above comments, this part is the one which takes each images and makes the calendar-a-day. Can this be modified to accept a text file instead of an image file?– AkuJan 4, 2012 at 14:03
\daypage{183}{Monday}{04}{Jul 2005}{Independence Day}{~}
say. Since you mention "math puzzles", I assume that your "pictures" might include a bunch of text, perhaps some math, and perhaps even the occasional graphic.