I'm new to LaTeX and want to make a journal. I've used this to generate a journal from files in multiple directories.
My main problem is that having various folders named Jan/Feb/...Ago/Dec... makes them look nasty in explorer (alphabetical makes the months show up funny: Ago then Dec then Jan ...) so I prefixed my folders with 01Jan 02Feb ect...
But I don't want the prefixed number to show, so I want to do something like
\substring{01Jan}{3}{5}
Here's what I've got so far and I get the following error: "Use of \myRenamedMonth doesn't match its definition
\documentclass{tufte-book} % producing handouts and books according to the style of Edward R. Tufte and Richard Feynman.
\usepackage{lipsum}
\usepackage{tikz} % Tikz is a powerful tool to create graphic elements in LATEX
\usepackage{xifthen} % extended if then else commands.
\usepackage{stringstrings} % \substring{abcdefgh}{3}{6} gives me the 3rd to 6th char = "cdef"
\newenvironment{loggentry}[2]% date, heading
{\noindent\textbf{#2}\marginnote{#1}\par}{\vspace{0.5cm}}
\def\?#1{}
\pgfmathtruncatemacro{\StartYear}{2017}
\pgfmathtruncatemacro{\EndYear}{2018}
\newcommand{\writetitle}{0}
\newcommand{\mytitle}[1]
{ \ifthenelse{\writetitle=1}{#1}{}
}
\newread\mysource
\begin{document}
\foreach \Year in {\StartYear,...,\EndYear}
{ \foreach \Month in {01Jan,02Fev,03Mar,04Abr,05Mai,06Jun,07Jul,08Ago,09Set,10Out,11Nov,12Dez}
{ \foreach \Day in {01,02,03,04,05,06,07,08,09,10,...,31}
{ \IfFileExists{\Year/\Month/\Day}
{ \openin\mysource=\Year/\Month/\Day.tex
\read\mysource to \firstline
\closein\mysource
\xdef\writetitle{1}
\def \myRenamedMonth=\substring{\Month}{3}{6}
\begin{loggentry}{\Year - \myRenamedMonth - \Day}{\firstline}
\xdef\writetitle{0}
\input{\Year/\Month/\Day}
\end{loggentry}
}
{ % files does not exist, so nothing to do
}
}
}
}
\end{document}
EDIT: the problem was solved by using the correct syntax as apointed by Skillmon (please make submit it as an anwser so I can accept it :) but raised another problem... The second dash "-" is getting "eaten up" and printing:
2018 - Jan 03
instead of 2018 - Jan - 03
\def\myRenamedMonth=isn't correct syntax. It should be\def\myRenamedMonth{\substring{\Month}{3}{6}}. If you always need to remove the first 2 characters out of 5 you could as well use the naive way:\def\RemoveTwoFromFive#1#2#3#4#5\q{#3#4#5}and then\xdef\myRenamedMonth{\expandafter\RemoveTwoFromFive\Month\q}. – Skillmon Mar 18 '18 at 21:06