Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to compose a TikZ calendar, but only want workdays printed. From the manual (I'm using v2.1):

57.1.2 Checking Dates

...

  • workday Passed by Mondays, Tuesdays, Wednesdays, Thursdays, and Fridays.
  • weekend Passed Saturdays and Sundays.

I know I can pass formatting options or node shapes on top of dates based on these checks... but how can I completely omit them from being printed?

Or is a date check not the way to go about this?

I'm using week list since it's so convenient for a calendar format layout by just using \calendar[dates=2012-01-01 to 2012-01-last] vs. what I think I might have to do to get what I want, which is pass each weekly range for every month. This quadruples my lines of code and really reduces the re-usability of my document.

Is there a better way? I didn't see any examples of this in the manual.


If reproducible code is required, I'm looking for this but with no weekends printed:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar,shapes.geometric}

\begin{document}

\begin{tikzpicture}
   [every calendar/.style={
       month label above left,
       month text={\textit{\%mt}},
       week list}]

   \calendar[dates=2012-01-01 to 2012-01-last] ;

\end{tikzpicture}

\end{document}
share|improve this question
    
Thanks for the full MWE. –  percusse Sep 11 '12 at 0:31
add comment

1 Answer

up vote 8 down vote accepted

You can use the if(weekend) [<do something with this weekend>] syntax. For example, you could set the weekend's color to red:

\calendar[dates=2012-01-01 to 2012-01-last] if(weekend) [red];

or, if you want it to disappear, to white. But this still prints out the actual node text. Or, even worse, you have white text on a colored background.

With the argument coordinate (short for shape=coordinate) you can transform the day node to a coordinate. A coordinate has no text.
Therefore there is not even a node text that is just hidden.

Code

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar,shapes.geometric}

\begin{document}
\begin{tikzpicture}
   [every calendar/.style={
       month label above left,
       month text={\textit{\%mt}},
       week list}]
   \calendar[dates=2012-01-01 to 2012-01-last] if(weekend) [shape=coordinate];
\end{tikzpicture}
\end{document}

Output

Note: The yellow boxes are a two-line selection that shows that there is no hidden text. Compare with the [white] version on the right.

Output produces by the posted codeenter image description here

share|improve this answer
1  
That's a nice shortcut. –  percusse Sep 11 '12 at 0:15
    
Awesome! I had tried using if(weekend) and just passing no argument, hoping it would do nothing... but I think it defaults to doing "nothing" in the sense of "nothing other than what it was going to do anyway." I'll try this after lunch and accept if successful. Thanks a ton! –  Hendy Sep 11 '12 at 16:26
    
@Hendy I'm glad I could help. Yes, the [] argument just gets passed to the internally \node … {…} command as \node[] … {…}. It would just have no effect. –  Qrrbrbirlbel Sep 11 '12 at 16:39
    
Just tried this and worked wonderfully. I added it to every calendar/.style={..., if={(weekend) [shape=coordinate]}, ... } so that I didn't have to add it to every instance. Fantastic and clever solution! –  Hendy Sep 12 '12 at 17:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.