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.

Here is my code adapted from the TikZ manual. I would like to do an agricultural calendar, but I am having trouble with the positions of the nodes. I appreciate any help. Thanks.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calendar,shadings}
\usetikzlibrary{calc}
\def\termin#1#2{
\node [text width= 3.4cm] at
($(cal-#1)+(0em, 0em)$) {\textcolor{red}\tiny{#2}};
 }



 \begin{document}
 \sffamily

 % A counter, since TikZ is not clever enough (yet) to handle
 % arbitrary angle systems.
 \newcount\mycount


 \begin{tikzpicture}
 [transform shape,
 every day/.style={anchor=mid,font=\fontsize{6}{6}\selectfont}]
 %\node{\normalsize 2012};
 \foreach \month in
 {1,2,...,12}
 {
 % Compute angle:
 \mycount=\month
 \advance\mycount by -1
 \multiply\mycount by 30
 \advance\mycount by -90
 % The actual calendar
 \calendar at (\the\mycount:6cm)
 [
 dates=2012-\month-01 to 2012-\month-last, name=cal,
 ]
 if (day of month=1) {\tikzmonthcode}
 if (equals = 2012-11-20) [red]
 if (equals = 2012-03-10) [red] 
 if (all)
 {
 % Again, compute angle
 \mycount=1
 \advance\mycount by -\pgfcalendarcurrentday
 \multiply\mycount by 11
 \advance\mycount by 90
 \pgftransformshift{\pgfpointpolar{\mycount}{1.4cm}}
 };
 }

 \termin{2012-11-20}{\color{red}Soybean planting}
 \termin{2012-03-10}{\color{red}Soybean  harvesting}

 \end{tikzpicture}
 \end{document}

enter image description here

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You could add a parameter to the termin to specify positioning options. Below I have applied a left=2.5ex positioning to the "Soybean planting" and a right=1.5ex to the "Soybean harvesting".

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{calendar,shadings}
\usetikzlibrary{calc}

\newcommand{\termin}[3][]{%
    \node [#1] at
        ($(cal-#2)+(0em, 0em)$) {\textcolor{red}{#3}};
}


 \begin{document}
 \sffamily

 % A counter, since TikZ is not clever enough (yet) to handle
 % arbitrary angle systems.
 \newcount\mycount

\noindent
 \begin{tikzpicture}
 [transform shape, scale=0.85,
 every day/.style={anchor=mid,font=\fontsize{6}{6}\selectfont}]
 %\node{\normalsize 2012};
 \foreach \month in
 {1,2,...,12}
 {
 % Compute angle:
 \mycount=\month
 \advance\mycount by -1
 \multiply\mycount by 30
 \advance\mycount by -90
 % The actual calendar
 \calendar at (\the\mycount:6cm)
 [
 dates=2012-\month-01 to 2012-\month-last, name=cal,
 ]
 if (day of month=1) {\tikzmonthcode}
 if (equals = 2012-11-20) [red]
 if (equals = 2012-03-10) [red] 
 if (all)
 {
 % Again, compute angle
 \mycount=1
 \advance\mycount by -\pgfcalendarcurrentday
 \multiply\mycount by 11
 \advance\mycount by 90
 \pgftransformshift{\pgfpointpolar{\mycount}{1.4cm}}
 };
 }

 \termin[left=2.5ex]{2012-11-20}{\color{red}Soybean planting}
 \termin[right=1.5ex]{2012-03-10}{\color{red}Soybean harvesting}

 \end{tikzpicture}
 \end{document}
share|improve this answer
    
Thanks Peter. Easy when we know! –  Alexandre Apr 29 at 11:25

Here is one answer.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calendar,shadings,positioning}
\usetikzlibrary{calc}
\def\termin#1#2#3#4{%
\node [align=left,text=red,font=\tiny, #2 =0ex   of cal-#1,anchor=#3] {#4};
 }%

 \begin{document}
 \sffamily

 % A counter, since TikZ is not clever enough (yet) to handle
 % arbitrary angle systems.
 \newcount\mycount


 \begin{tikzpicture}
 [transform shape,
 every day/.style={anchor=mid,font=\fontsize{6}{6}\selectfont}]
 %\node{\normalsize 2012};
 \foreach \month in
 {1,2,...,12}
 {
 % Compute angle:
 \mycount=\month
 \advance\mycount by -1
 \multiply\mycount by 30
 \advance\mycount by -90
 % The actual calendar
 \calendar at (\the\mycount:6cm)
 [
 dates=2012-\month-01 to 2012-\month-last, name=cal,
 ]
 if (day of month=1) {\tikzmonthcode}
 if (equals = 2012-11-20) [red]
 if (equals = 2012-03-10) [red]
 if (all)
 {
 % Again, compute angle
 \mycount=1
 \advance\mycount by -\pgfcalendarcurrentday
 \multiply\mycount by 11
 \advance\mycount by 90
 \pgftransformshift{\pgfpointpolar{\mycount}{1.4cm}}
 };
 }

 \termin{2012-11-20}{left}{east}{Soybean planting}
 \termin{2012-03-10}{right}{west}{Soybean  harvesting}

 \end{tikzpicture}
 \end{document}

enter image description here

share|improve this answer
    
Good solution Kumar, thanks. –  Alexandre Apr 29 at 11:33

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.