# Using Tikz Calendar in Portuguese as a Syllabus

I have been trying to use this question answer calendar among pages and in portuguese without much luck. For instance, when I attempt to display a larger than one page calendar, instead of having it spread over pages, it simple truncate. Furthermore, I was unsucessful on finding on the documentation any means of renaming days and months to my native language (portuguese-br) or if any setting would be able to do it.

Some of the code provided on alternative websites such as a brazilian website and the tikz documentation on section 28, page 323 of the pdf strangely do not compile on my Latex TextMate build which is running on my mac os lion.

In short, what I am looking for is:

1. A way to translate it to portuguese-br
2. Be able to spam the length of time larger than one page. In fact, the time length I am looking for is already shown on the code I current have and pdf generated attached for clarification.

My tex file which can be compiled directly into a pdf and show the afore mentioned problems can be found here.

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[brazilian]{babel}
\usepackage[T1]{fontenc}

\usepackage{lscape}
\usepackage{longtable}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{calendar}

\newcounter{lecture}
\setcounter{lecture}{1}

\newcommand{\scheme}[4]{% Lecture Name, Aim, Objectives, Activities
\expandafter\gdef\csname lecture \arabic{lecture}\endcsname{#1}%
\arabic{lecture}. \stepcounter{lecture} & \raggedright #1 & Aim: #2

Objectives:
#3
&
#4
\\
\hline
}

\newcounter{topic}
\renewcommand{\thetopic}{\Roman{topic}}
\setcounter{topic}{0}

\newcommand{\topic}[1]{%
\multicolumn{4}{l}{\stepcounter{topic}
\rule{0pt}{20pt} \Large \textbf{Topic \thetopic: #1}}
\\* \multicolumn{4}{l}{\parbox{0pt}{\vspace*{12pt}\hspace*{-\tabcolsep}\rule{\fullwidth}{.5pt}}} \\*
}

\newcounter{excursion}
\renewcommand{\theexcursion}{\Alph{excursion}}
\setcounter{excursion}{0}

\newcommand{\excursion}[1]{%
\multicolumn{4}{l}{\stepcounter{excursion}
\rule{0pt}{20pt} \Large \textbf{Excursion \theexcursion: #1}}
\\* \multicolumn{4}{l}{\parbox{0pt}{\vspace*{12pt}\hspace*{-\tabcolsep}\rule{\fullwidth}{.5pt}}} \\*
}

\newenvironment{objectives}{%
By the end of this lecture a student should be able to:
\enumerate}{\endenumerate}

\pagestyle{empty}

\setlength{\hoffset}{.5\textwidth}
\setlength{\textwidth}{19cm}
\setlength{\voffset}{.5\textheight}
\setlength{\textheight}{27cm}

\newlength{\fischeme}
\newlength{\sescheme}
\newlength{\thscheme}
\newlength{\foscheme}
\newlength{\fullwidth}

\setlength{\fischeme}{.075\textheight}
\setlength{\sescheme}{.125\textheight}
\setlength{\thscheme}{.4\textheight}
\setlength{\foscheme}{.35\textheight}

\setlength{\fullwidth}{\fischeme}

\begin{document}
\begin{landscape}

\begin{center}
{\Huge MA3402 Analysis on Manifolds}
\end{center}

\vfill

\begin{longtable}{|p{\fischeme}|p{\sescheme}|p{\thscheme}|p{\foscheme}|}
\hline
Lecture Number & Lecture Name & Aims and Objectives & Activities,
\hline \endfoot
\hline

\topic{Manifolds}

\scheme{%
Calculus Review
}{%
To recall the key concepts of calculus.
}{%
\begin{objectives}
\item List the main definitions and results of calculus
\item Understand the key role of approximation in the application of
analysis
\end{objectives}
}{%
\begin{enumerate}
\item Recall quiz
\item Vote for the Most Valuable Theorem''
\item How close is close enough?
\end{enumerate}
}

\excursion{Lie Groups}

\scheme{%
Lie Groups
}{%
To introduce basic Lie groups
}{%
\begin{objectives}
\item Prove that multiplication and inverse are smooth maps on
$$Gl_n$$.
\item Prove the same for $$O_n$$.
\item Know the definition of a principal bundle (for $$Gl_n$$ and
$$O_n$$).
\item Know how to construct associated fibre bundles.
\end{objectives}
}{%
}

\hline\hline

\scheme{%
Problem Session
}{%
To go through the fifth problem sheet.
}{%
}{%
Fifth problem sheet
}

\topic{Differentiation}

\scheme{%
Differentiation on Manifolds
}{%
To explore the different types of differentiation that are possible.
}{%
\begin{objectives}
\item Define the Lie bracket of vector fields in terms of flow.
\item Define the Lie derivative of tensors.
\end{objectives}
}{%
\begin{enumerate}
\item Differentiation as change under infinitesimal perturbation.
\end{enumerate}
}

\end{longtable}
\end{landscape}

%\setcounter{lecture}{0}

\tikz [every day/.style={anchor=east}]
\calendar [dates=2013-07-10 to 2014-14-01, day list downward, month label above left,day text={\%w. \%d=}]
%if (Monday) {\draw (-0.29,0) circle (8pt);} Circulo para provas
if (Sunday) [black!50,nodes={draw=none}] %Cinza para dias sem aula
if (Monday,Tuesday) [red]
if (Monday,Tuesday) {\node[anchor=west] at (.5,0) {\stepcounter{lecture}Aula \arabic{lecture} \csname lecture \arabic{lecture}\endcsname};};

\end{document}


I appreciate any help on how to go about this, there aren't many syllabus template out there as .tex files. Let alone that it is easy to translate. If it comes down to writing the 12 months and 7 days in my own native language I wouldn't mind as a solution as well, so long it could be explained how with 1 day and 1 month example.

I hope the question is not too specific. Thank you.

• Would a solution using the termcal package work? It's not too difficult to translate. Nov 9 '13 at 23:49
• I would actually like to stick to this one because of the space :( However, if no answer is provided ever, I'd appreciate yours. In any case, there is no guide on translating it afaik so it could also be of help to other people. Thank you! Nov 10 '13 at 0:07
• I've added a termcal answer then. It's a great package. But there are plenty of TikZ experts around who might be able to answer the TikZ version. Nov 10 '13 at 0:20
• Could you add an image (might as well be a drawing of yourself) how you want your output to look like? I am looking at your code, at the linked question and at the answer of this question itself and can’t really make out what you really want to achieve here. What is your input? What is your output? (The translation issue is hardly problem, if worse comes to worse—no babel/pgfcalendar support—, you just have to type in the names and abbreviations of the months and weekdays in the right order and PGF does use them instead.) Nov 10 '13 at 2:27
• The pgfcalendar package doesn’t do much on its own. It just iterates through the dates and execute options. These options need to be set up correctly and properly. TikZ defines a few styles that do exactly this (month list, week list, etc.). I assume that this is the real task in this question looking at the answer. Nov 10 '13 at 2:40

As an ignorant monolingual British English speaker I haven't familiarized myself with the language options in LaTeX and its packages. However, the beamer class comes with the translator package and the tikz calendar library does use this under the covers. The PGF manual (very briefly) mentions the translator package in the section "Date and calendar utility macros".

In addition to not understanding LaTeX language options I am not that familiar with the translator package or the calendar library. But by "fooling around" I seem to have something almost working which may or may not be useful.

Annoyingly I can't get it to work with brazilian language options, but I can get it to work by specifying portuguese. Apologies for any mistranslations.

\documentclass{standalone}

\usepackage[portuguese]{babel}

\usepackage{tikz}

\usetikzlibrary{calendar}

\usepackage[portuguese]{translator}

\deftranslation[to=portuguese]{January}{Janeiro}
\deftranslation[to=portuguese]{February}{Fevereir}
\deftranslation[to=portuguese]{March}{Mar\c co}
\deftranslation[to=portuguese]{April}{Abril}
\deftranslation[to=portuguese]{May}{Maio}
\deftranslation[to=portuguese]{June}{Junho}
\deftranslation[to=portuguese]{July}{Julho}
\deftranslation[to=portuguese]{August}{Agosto}
\deftranslation[to=portuguese]{September}{Setembro}
\deftranslation[to=portuguese]{October}{Outubro}
\deftranslation[to=portuguese]{November}{Novembro}
\deftranslation[to=portuguese]{December}{Dezembro}

\deftranslation[to=portuguese]{Mon}{2\textsuperscript{a}}
\deftranslation[to=portuguese]{Tue}{3\textsuperscript{a}}
\deftranslation[to=portuguese]{Wed}{4\textsuperscript{a}}
\deftranslation[to=portuguese]{Thu}{5\textsuperscript{a}}
\deftranslation[to=portuguese]{Fri}{6\textsuperscript{a}}
\deftranslation[to=portuguese]{Sat}{Sab}
\deftranslation[to=portuguese]{Sun}{Dom}

\newcounter{lecture}
\setcounter{lecture}{1}

\begin{document}

\tikz[every day/.style={anchor=east}]
\calendar [dates=2013-11-1 to 2013-11-14,day list downward, month label above left,day text={\%w. \%d=}]
if (Sunday) [black!50,nodes={draw=none}] %Cinza para dias sem aula
if (Monday,Tuesday) [red]
if (Monday,Tuesday) {\node[anchor=west] at (.5,0)
{\stepcounter{lecture}Aula \arabic{lecture} \csname lecture \arabic{lecture}\endcsname};};

\end{document}


Regarding spanning the calendar over multiple pages: as the calendar is inside a tikzpicture which is put into the document inside a TeXbox, it cannot currently be split over pages. So, the calendar would have to be split manually and placed on each page.

It can, however be automated somewhat, although it is a bit crude. Below, each week is a separate picture.

\documentclass{article}
\usepackage[margin=1in]{geometry}

\usepackage{tikz}

\usetikzlibrary{calendar}

\newcounter{lecture}
\setcounter{lecture}{1}
\newcount\julianstartday

\begin{document}

\pgfcalendardatetojulian{2013-11-4}{\julianstartday}

\foreach \week in {1,...,7}{
\pgfcalendarjuliantodate{\julianstartday}{\y}{\m}{\d}
%
\tikz[every day/.style={anchor=base east},
every month/.style={xshift=-1.5cm, anchor=base east},
% Always do the month code get the bounding box of the picture
% right, but only show the text on the first of the week.
month code={%
\node[every month]{\ifdate{Monday}{\tikzmonthtext}{\phantom\tikzmonthtext}};
},
execute at begin day scope={%
\pgftransformyshift{\pgfcalendarcurrentweekday*-1cm+1cm}%
\tikzmonthcode
}
]
\calendar [dates=\y-\m-\d to \y-\m-\d+6,day text={\%w. \%d=}]
if (Sunday) [black!50,nodes={draw=none}] %Cinza para dias sem aula
if (Monday,Tuesday) [red]
if (Monday,Tuesday) {\node[anchor=base west] at (.5,0)
{\stepcounter{lecture}Aula \arabic{lecture} \csname lecture \arabic{lecture}\endcsname};};
\vskip0.5cm
}
\end{document}


In response to the comments: is it possible to have a "not" rule or logical "and" rule in the \ifdate calculations, so that a date will be typeset in a particular way only if one of the rules is true?.

The answer is "sort of". By default if (Monday,Tuesday) evaluates to true if either Monday is true or Tuesday is true (i.e., logical "or").

However we can construct an and not holiday rule and provided it is the last rule in the condition it will do the job. Below I've tidied things away in some internal macros and provided a convenient \pgfcalendardeclareholiday macro. Note that Guy Fawkes day is not actually holiday in the UK, it is just a real date the corresponds with a lecture in the calendar.

\documentclass{standalone}

\usepackage[portuguese]{babel}

\usepackage{tikz}

\usetikzlibrary{calendar}

\usepackage[portuguese]{translator}

\deftranslation[to=portuguese]{January}{Janeiro}
\deftranslation[to=portuguese]{February}{Fevereir}
\deftranslation[to=portuguese]{March}{Mar\c co}
\deftranslation[to=portuguese]{April}{Abril}
\deftranslation[to=portuguese]{May}{Maio}
\deftranslation[to=portuguese]{June}{Junho}
\deftranslation[to=portuguese]{July}{Julho}
\deftranslation[to=portuguese]{August}{Agosto}
\deftranslation[to=portuguese]{September}{Setembro}
\deftranslation[to=portuguese]{October}{Outubro}
\deftranslation[to=portuguese]{November}{Novembro}
\deftranslation[to=portuguese]{December}{Dezembro}

\deftranslation[to=portuguese]{Mon}{2\textsuperscript{a}}
\deftranslation[to=portuguese]{Tue}{3\textsuperscript{a}}
\deftranslation[to=portuguese]{Wed}{4\textsuperscript{a}}
\deftranslation[to=portuguese]{Thu}{5\textsuperscript{a}}
\deftranslation[to=portuguese]{Fri}{6\textsuperscript{a}}
\deftranslation[to=portuguese]{Sat}{Sab}
\deftranslation[to=portuguese]{Sun}{Dom}

\newcounter{lecture}
\setcounter{lecture}{1}
\newcount\julianstartday

\makeatletter

% Macro to declare a holiday
\def\pgfcalendardeclareholiday#1#2{%
\pgfutil@namedef{pgf@calendar@holiday@#1@}{#2}%
}

\pgfkeys{/pgf/calendar/holiday/.code={%
\edef\date{\pgfcalendarifdateyear-\pgfcalendarifdatemonth-\pgfcalendarifdateday}%
\pgfutil@ifundefined{pgf@calendar@holiday@\date @}{%
\let\pgfcalendarholidayname=\pgfutil@empty%
}{%
% If the internal holiday macro has been defined indicate a match
\expandafter\let\expandafter\pgfcalendarholidayname\expandafter=\csname pgf@calendar@holiday@\date @\endcsname%
\pgfcalendarmatchestrue%
}%
}}

\pgfkeys{/pgf/calendar/and not holiday/.code={%
\edef\date{\pgfcalendarifdateyear-\pgfcalendarifdatemonth-\pgfcalendarifdateday}%
\pgfutil@ifundefined{pgf@calendar@holiday@\date @}{%
% If the internal holiday macro has been defined *and*
% previous tests have returned true return true
\ifpgfcalendarmatches%
\pgfcalendarmatchestrue%
\else%
\pgfcalendarmatchesfalse%
\fi%
\let\pgfcalendarholidayname=\pgfutil@empty%
}{%
\expandafter\let\expandafter\pgfcalendarholidayname\expandafter=\csname pgf@calendar@holiday@\date @\endcsname%
\pgfcalendarmatchesfalse%
}%
}}

\begin{document}

\pgfcalendardeclareholiday{2013-11-15}{Proclama\c c\~ ao da Rep\'blica}

\pgfcalendardeclareholiday{2013-11-05}{Guy Fawkes}% <- not a real holiday

\pgfcalendardatetojulian{2013-10-28}{\julianstartday}

\begin{minipage}{4in}
\foreach \week in {1,...,3}{
\pgfcalendarjuliantodate{\julianstartday}{\y}{\m}{\d}
%
\tikz[every day/.style={anchor=base east},
every month/.style={xshift=-1.5cm, anchor=base east},
% Always do the month code get the bounding box of the picture
% right, but only show the text on the first of the week
month code={%
\node[every month]{\ifdate{Monday,day of month=1}{\tikzmonthtext}{\phantom\tikzmonthtext}};
},
execute at begin day scope={%
\pgftransformyshift{\pgfcalendarcurrentweekday*-1cm+1cm}%
\tikzmonthcode
}
]
\calendar [dates=\y-\m-\d to \y-\m-\d+6,day text={\%w. \%d=}]
if (Sunday) [black!50,nodes={draw=none}] %Cinza para dias sem aula
if (Monday,Tuesday) [red]
if (holiday) [blue]
if (holiday) {\node [anchor=base west, blue] at (.5,0) {\pgfcalendarholidayname};}
if (Monday,Tuesday, and not holiday) {\node[anchor=base west] at (.5,0)
{\stepcounter{lecture}Aula \arabic{lecture} \csname lecture \arabic{lecture}\endcsname};};
\vskip0.5cm
}
\end{minipage}
\end{document}


• Hi Mark, this answer is perfect for me. I have just one minor comment before accepting it: Do you have any idea on how to create a negative condition? Any pointer on the documentation for these would be appreciated as well, I can't find it on google at all! Ideally I wanted to add manually dates that are holidays in my country so the it doesn't show a 'Lecture i' on those days. So that would replace the third conditional on the 'if' to something like if(Monday and Tuesday and not equals=2014-04-11 and not equals=2014-06-11 and not ...) etc with the current existing then. Nov 10 '13 at 18:53
• @OeufcoquePenteano, a bit tricky as far as I can tell. Particularly as the if syntax returns true if any of the listed conditions are true (so "logical or"). The manual explains how it is possible to define new conditions (see "Checking Dates" in section "Date and Calendar Utility Macros" in the manual), however it uses the \define@key command which has been replaced with \pgfkeys. Basically you could write \pgfkeys{/pgf/calendar/lecture/.code={ ... }} and replace the ... with the required code as outlined in the manual. Nov 10 '13 at 20:31
• Thank you so much, I ended up just playing around with the counter and gray color so that the Lecture number would be repeated. That way, at least my students can quickly tell the class was delayed for some reason and when that happened as well. I am accepting this answer! :-) Nov 10 '13 at 21:03
• @OeufcoquePenteano, I've update the answer with a better explanation and a possible workaround. Nov 11 '13 at 7:28

Although this is not a direct answer to your question, the termcal package, which provides a very simple to use calendar designed for class syllabuses is very easy to localize. There are really only three commands that need to be redefined: one for the abbreviations of the names of the months, one for the formatting of ordinal numbers, and one for the ordering of the month and number. Here's the example from the linked question translated into Portuguese.

\documentclass{article}
\usepackage{fixltx2e}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{termcal}

% Beginning of translation code
\makeatletter
% redefine the month abbreviations (these can be full names if you prefer)
\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}
% redefine the printing of the date
% for Portuguese, this is either just the number itself, or
% \the\c@date\textsuperscript{o} depending on if you want an ordinal marker
% other languages might require a more complex redefinition
\renewcommand\ordinaldate{\the\c@date}
% redefine how a date that is the first in a new month is printed
% This would normally be redefined however you like anyway
\renewcommand{\calprintdate}{%
\ifnewmonth\framebox{\ordinaldate~de~\monthname}%
\else \ordinaldate\fi
}
\makeatother
% End of translation code

% Few useful commands (our classes always meet either on Monday and Wednesday
% or on Tuesday and Thursday)

\newcommand{\MWClass}{%
\calday[segunda-feira]{\classday} % Monday
\skipday % Tuesday (no class)
\calday[quarta-feira]{\classday} % Wednesday
\skipday % Thursday (no class)
\skipday % Friday
\skipday\skipday % weekend (no class)
}

\newcommand{\TRClass}{%
\skipday % Monday (no class)
\calday[terça-feira]{\classday} % Tuesday
\skipday % Wednesday (no class)
\calday[quinta-feira]{\classday} % Thursday
\skipday % Friday
\skipday\skipday % weekend (no class)
}

\newcommand{\Holiday}[2]{%
\options{#1}{\noclassday}
\caltext{#1}{#2}
}

\begin{document}

\paragraph*{Tentative Schedule:}
\begin{calendar}{1/11/2010}{16} % Semester starts on 1/11/2010 and last for 16
% weeks, including finals week
\setlength{\calboxdepth}{.3in}
\TRClass
% schedule
\caltexton{1}{1.1, 1.2 Review}
\caltextnext{1.3, 1.4 Review}
\caltextnext{2.1, 2.2 Linear Equations}
% ... and so on

% Holidays
\Holiday{1/18/2010}{Martin Luther King Day}
\Holiday{3/8/2010}{Spring Break}
% ... and so on

\options{4/26/2010}{\noclassday} % finals week
\options{4/27/2010}{\noclassday} % finals week
\options{4/28/2010}{\noclassday} % finals week
\options{4/29/2010}{\noclassday} % finals week
\options{4/30/2010}{\noclassday} % finals week
\caltext{4/27/2010}{\textbf{Final Exam}}
\end{calendar}
\end{document}


• Many thanks, I upvoted it, and in case no more answers are provided for a while that fully meets the criteria of my question I will accepted it and use this as an alternative! Nov 10 '13 at 0:20