Information and discussion about graphics, figures & tables in LaTeX documents.
svend_tveskaeg
Posts: 478 Joined: Sun Jul 12, 2009 5:31 am
Post
by svend_tveskaeg » Tue Jan 08, 2013 6:02 pm
Hi all.
Consider the following MWE:
Code: Select all
\documentclass[a4paper,12pt,landscape]{article}
\usepackage{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[hmargin=2.4cm,vmargin=3cm]{geometry}
\usepackage{slashbox}
\usepackage{array}
\pagestyle{empty}
\begin{document}
\begin{center}
\Huge{\textbf{Cleaning schedule}}
\end{center}
\vspace{5ex}
\begin{center}
\large
\begin{tabular}{l | @{\hspace{1cm}} c @{\hspace{1cm}} c @{\hspace{1cm}} c @{\hspace{1cm}} c @{\hspace{1cm}} c}
\textbf{\backslashbox{Name}{Place}} & Kitchen & Bath & Toilet & Hallway & \textit{Week off}\\
\hline & & & & & \\
Name~A & Week~1 & Week~2 & Week~3 & Week~4 & Week~5 \\[2ex]
Name~B & Week~2 & Week~3 & Week~4 & Week~5 & Week~1 \\[2ex]
Name~C & Week~3 & Week~4 & Week~5 & Week~1 & Week~2 \\[2ex]
Name~D & Week~4 & Week~5 & Week~1 & Week~2 & Week~3 \\[2ex]
Name~E & Week~5 & Week~1 & Week~2 & Week~3 & Week~4
\end{tabular}
\end{center}
\end{document}
Is it possible to compile without changing anything every week and get the correct week numbers every time?
I hope this makes sense.
Thank you in advance!
P.S.: The slashbox package (not part of TeX Live) is needed to compile the code.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
CrazyHorse
Posts: 351 Joined: Sat Aug 02, 2008 8:47 am
Post
by CrazyHorse » Tue Jan 08, 2013 7:19 pm
svend_tveskaeg wrote:
P.S.: The slashbox package (not part of TeX Live) is needed to compile the code.
For your question and your example it is absolutely not important to use that package.
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Tue Jan 08, 2013 9:13 pm
svend_tveskaeg wrote: Is it possible to compile without changing anything every week and get the correct week numbers every time?
Hi Svend. I don't think I get what you mean (I have an idea, but...). Could you elaborate what you're trying to achieve? And maybe what input you'd ideally want to use?
Regards
svend_tveskaeg
Posts: 478 Joined: Sun Jul 12, 2009 5:31 am
Post
by svend_tveskaeg » Tue Jan 08, 2013 11:53 pm
@Herbert: Sorry. I wasn't sure if it was important to get the diagonal line now in order not to forget it in the final table.
@Clemens: Assume the table in the example was compiled last week, then the output would be correct. If it was compiled this week, it should be
"Week 1" --> "Week 2"
"Week 2" --> "Week 3"
"Week 3" --> "Week 4"
"Week 4" --> "Week 5"
"Week 5" --> "Week 6"
and next week Week 3 to Week 7. I hope this makes sense.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Wed Jan 09, 2013 12:13 am
Ok, let's see if I understood you right:
the only thing that needs to change is the number after “week”.
(just interpreting here) the week numbers refer to the official week numbers of the year
the numbers in the table always always span five weeks (1--5, 2--6, 3--7 and so one)
If the above is right and all you want to do is update the file once a week then maybe something like this:
Code: Select all
\documentclass{article}
\newcounter{week}
\setcounter{week}{2}
\newcommand\week[1]{week~\the\numexpr\value{week}+#1-1\relax}
\begin{document}
\begin{tabular}{lccccc}
& \week{1} & \week{2} & \week{3} & \week{4} & \week{5} \\
& \week{2} & \week{3} & \week{4} & \week{5} & \week{1} \\
& \week{3} & \week{4} & \week{5} & \week{1} & \week{2} \\
& \week{4} & \week{5} & \week{1} & \week{2} & \week{3} \\
& \week{5} & \week{1} & \week{2} & \week{2} & \week{4}
\end{tabular}
\end{document}
Regards
svend_tveskaeg
Posts: 478 Joined: Sun Jul 12, 2009 5:31 am
Post
by svend_tveskaeg » Wed Jan 09, 2013 12:38 am
This is almost what I want.
Is it possible to have it automatically catch the week number instead of having to change the value of \setcounter
every week, i.e., something similar to \today
but for weeks?
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Wed Jan 09, 2013 12:50 am
Probably... I don't know, exactly. Maybe one of the
date/time related packages has a convenient way for this. Actually,
this one seems to get the week number from a given date, but I don't have it installed.
It didn't seem
too inconvenient to me to update the week number only...?!
Regards
svend_tveskaeg
Posts: 478 Joined: Sun Jul 12, 2009 5:31 am
Post
by svend_tveskaeg » Wed Jan 09, 2013 12:52 am
No, it is not inconvenient at all to change the counter. I could just very well forget to do it, that is all.
I just found out that I would like the week numbers to be calculated modulo 52. Is this possible?
Update
I have found
this page but I cannot figure out how to use it.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Wed Jan 09, 2013 11:21 pm
svend_tveskaeg wrote: I just found out that I would like the week numbers to be calculated modulo 52. Is this possible?
The question
How do I calculate n modulo 3 in LaTeX? over at TeX.sx has (if I haven't miscounted) eight answers. Hopefully one is the right one for you
I particularly like @egreg's solution:
Code: Select all
\def\truncdiv#1#2{((#1-(#2-1)/2)/#2)}
\def\moduloop#1#2{(#1-\truncdiv{#1}{#2}*#2)}
\def\modulo#1#2{\number\numexpr\moduloop{#1}{#2}\relax}
\modulo{57}{52}
Regards
svend_tveskaeg
Posts: 478 Joined: Sun Jul 12, 2009 5:31 am
Post
by svend_tveskaeg » Thu Jan 10, 2013 12:01 am
Thank you, Clemens.
I am not sure how to combine the two solution, in order to get yours but with week numbers modulo 52.
Can someone help with this?
Last edited by
svend_tveskaeg on Thu Jan 10, 2013 12:19 am, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)