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.

As the title implies, I would like to use LaTeX to keep a personal diary. I've been dumping my entries in a single file which has become unwieldy over time. Ideally I'd find a package (or collection of shell scripts) which assists me in maintaining a consistent directory structure and automatically headlining entries with their respective date.

I haven't found anything relevant in the CTAN repository, so I'm turning to you for advice. If there's no readily available solution, I might sit down and learn how to create custom packages.

Thank you very much!

share|improve this question
1  
Do you want to just throw in some entries with a date and let LaTex order them, or do you just want some consistent look and are willing to take care of the ordering yourself? –  Tom Bombadil Aug 24 '12 at 2:04
    
A consistent look is important to me. Ideally it would suffice to put an entry into files with a path matching the pattern /year/month/day.tex, and LaTeX would take care of putting the entries at the right place and include the date of writing in a pleasant-looking fashion. –  user1428640 Aug 24 '12 at 9:37
3  
Depending on how comfortable you feel with Emacs, you might want to look at org-mode (orgmode.org), and then export to TeX when you want to "generate" a nicely typeset version of your journal. –  mvarela Aug 24 '12 at 14:40
1  
\def\entry{\readthoughts{\today}}\par\entry –  Steven B. Segletes Jul 18 '13 at 9:49
1  
I just read the question and thought "what you really want is Org-mode". But @mvarela beat me to it... –  mbork Nov 17 '13 at 19:47

2 Answers 2

up vote 36 down vote accepted

As you can't comment yet, here's a proposition using the tufte-latex class and a custom environment. This is just what I made up, you could edit your question to specify what format and features you would like. The lipsum package is just used for some dummy text.

\documentclass{tufte-book}
\usepackage{lipsum}

\newenvironment{loggentry}[2]% date, heading
{\noindent\textbf{#2}\marginnote{#1}\\}{\vspace{0.5cm}}

\begin{document}


\begin{loggentry}{2009-Oct-31}{Snow}
    \lipsum[1]
\end{loggentry}

\begin{loggentry}{2010-Dez-31}{Water of Life}
    \lipsum[2]
\end{loggentry}

\begin{loggentry}{2011-Nov-15}{Cold}
    \lipsum[3-5]
\end{loggentry}

\begin{loggentry}{2012-Aug-24}{Sunrise}
    \lipsum[6-7]
\end{loggentry}

\end{document}

enter image description here


Edit 1: Here's an automated version. It assumes your directory to be of the form /Year/Month/Day.tex, formatted as e.g. 2012/Aug/24.tex, so the month is just the first three letters. The individual .tex files have only the requirement to have the first line as \mytitle{<The actual title here>}.

This solutions makes use of Peter Grill's answer to "How to iterate through the name of files in a folder".

The main file:

\documentclass{tufte-book}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{xifthen}

\newenvironment{loggentry}[2]% date, heading
{\noindent\textbf{#2}\marginnote{#1}\par}{\vspace{0.5cm}}

\def\?#1{}

\pgfmathtruncatemacro{\StartYear}{2008}
\pgfmathtruncatemacro{\EndYear}{2012}

\newcommand{\writetitle}{0}
\newcommand{\mytitle}[1]
{   \ifthenelse{\writetitle=1}{#1}{}
}

\newread\mysource

\begin{document}

\foreach \Year in {\StartYear,...,\EndYear}
{   \foreach \Month in {Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}
    {   \foreach \Day in {1,...,31}
        {   \IfFileExists{\Year/\Month/\Day}
                {   \openin\mysource=\Year/\Month/\Day.tex
                    \read\mysource to \firstline
                    \closein\mysource
                    \xdef\writetitle{1}
                    \begin{loggentry}{\Year - \Month - \Day}{\firstline}    
                        \xdef\writetitle{0}
                        \input{\Year/\Month/\Day}
                    \end{loggentry} 
        }
        {   % files does not exist, so nothing to do
        }

        }  
    }
}

\end{document}

A sample log entry file:

\mytitle{Something happened}
\lipsum[3-5]

The Output:

enter image description here

share|improve this answer
    
The OP's question seems to imply that one problem s/he faces is that there are many entries, so keeping them in a single file is not practical. Your answer could be improved by replacing \lipsum by the appropriate \input commands, perhaps putting each logentry in a separate file as you see fit. –  Bruno Le Floch Aug 24 '12 at 8:50
    
Your sample looks very pretty, thank you very much. As I stated in a comment above, I would like to put entries in files /year/month/day.tex and having LaTeX do the labour of figuring out the right order and headlining every entry with the date of its writing (extracted from the path name). I might write a shell script, but perhaps you can think of some other means. –  user1428640 Aug 24 '12 at 9:44
    
It is very nice! The only problem is that it looks for all the possible files. I believe that \write18 (aka --shell-escape) could be used to get the list of really existing files. Something like ls */*/* | sed 's/^/\\input' > ls.tex. Sorry, I have no experience with sheel escape, as well it is OS-dependent. –  tohecz Aug 24 '12 at 12:36
    
I don't know how that will be once you piled up 1000 files, but I was surprised how fast it compiled, given that in the given configuration it checks for 5*12*31=1860 files. –  Tom Bombadil Aug 24 '12 at 12:41
1  
Thank you - it helps me a lot in creating a personal journal template. Just want to mention that \marginpar works if you just want to use the article style instead of tufte-book.. –  M-V Oct 3 '12 at 11:14

My new code for diaries is as follows. It adds a note on the side, but without a box because it uses the marginnote package.

The environment file input.tex

\usepackage[top=4cm, bottom=2cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=3.5cm, marginparsep=0.75cm]{geometry}

\newcommand{\mybox}[1]{%
\marginnote{{\color{red}CAUTION!}\\{#1}}
}

\newlength\sidebar
 \newlength\envrule
 \newlength\envborder
 \setlength\sidebar{1.5mm}
 \setlength\envrule{0.4pt}
 \setlength\envborder{2mm}

\makeatletter
 \long\def\fboxs#1{%
   \leavevmode
   \setbox\@tempboxa\hbox{%
     \color@begingroup
       \kern\fboxsep{#1}\kern\fboxsep
     \color@endgroup}%
   \@frames@x\relax}
 \def\frameboxs{%
   \@ifnextchar(%)
     \@framepicbox{\@ifnextchar[\@frameboxs\fboxs}}
 \def\@frameboxs[#1]{%
   \@ifnextchar[%]
     {\@iframeboxs[#1]}%
     {\@iframeboxs[#1][c]}}
 \long\def\@iframeboxs[#1][#2]#3{%
   \leavevmode
   \@begin@tempboxa\hbox{#3}%
     \setlength\@tempdima{#1}%
     \setbox\@tempboxa\hb@xt@\@tempdima
          {\kern\fboxsep\csname bm@#2\endcsname\kern\fboxsep}%
     \@frames@x{\kern-\fboxrule}%
   \@end@tempboxa}
 \def\@frames@x#1{%
   \@tempdima\fboxrule
   \advance\@tempdima\fboxsep
   \advance\@tempdima\dp\@tempboxa
   \hbox{%
     \lower\@tempdima\hbox{%
       \vbox{%
         %\hrule\@height\fboxrule
         \hbox{%
          \vrule\@width\fboxrule
           #1%
           \vbox{%
             \vskip\fboxsep
             \box\@tempboxa
             \vskip\fboxsep}%
           #1%
           }%\vrule\@width\fboxrule}%
         }%\hrule\@height\fboxrule}%
                           }%
         }%
 }
 \def\esefcolorbox#1#{\esecolor@fbox{#1}}
 \def\esecolor@fbox#1#2#3{%
   \color@b@x{\fboxsep\z@\color#1{#2}\fboxs}{\color#1{#3}}}
 \makeatother


 \definecolor{exampleborder}{HTML}{FE642E}
 \definecolor{examplebg}{HTML}{CEF6EC}
 \definecolor{statementborder}{rgb}{.9,0,0}
 \definecolor{statementbg}{rgb}{1,1,1}

 \newenvironment{eseframed}{%
   \def\FrameCommand{\fboxrule=\the\sidebar  \fboxsep=\the\envborder%
   \esefcolorbox{exampleborder}{examplebg}}%
   \MakeFramed{\FrameRestore}}%
  {\endMakeFramed}

%\renewcommand\dateTurkish{\def\today{\number\day~%
 %\ifcase \month \or Ocak\or Şubat\or Mart\or Nisan\or Mayıs\or Haziran\or
 %  Temmuz\or Ağustos\or Eylül\or Ekim\or Kasım\or Aralık\fi\space
 %\number\year}}
%\dateTurkish

 \newcounter{diary}
%\numberwithin{uygulama}
\renewcommand{\thediary}{\arabic{diary}}

 %%% CODE ENVIRONMENT. PUT TEXT INTO COLORED FRAME %%%
 \newenvironment{diary}[2]
 {\par\medskip\refstepcounter{diary}%
 \hbox{%
 \fboxsep=\the\sidebar\hspace{-\envborder}\hspace{-.5\sidebar}%
 \colorbox{exampleborder}{%
 \hspace{\envborder}\footnotesize\sffamily\bfseries%
 \textcolor{white}{{#1}\ {#2}\enspace\hspace{\envborder}}
%\today
 }
 }
 \nointerlineskip\vspace{-\topsep}%
 \begin{eseframed}\noindent\ignorespaces%
 }
 {\end{eseframed}\vspace{-\baselineskip}\medskip}

The diary files are stored in a separate folder e.g 2013 and files are stored in it. An example of diary file 2013.tex:

%2013 Notes
\begin{diary}{Hello!}{07.18.2013}
\mybox{Put some text here for caution.}
 \lipsum[1]
\end{diary}


\begin{diary}{Second entry.}{07.19.2013}
\mybox{Put some text here for caution.}
 \lipsum[2]
\end{diary}

Main file

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{datetime}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{marginnote}
\usepackage{tikz}

\input{input}

\title{\Huge My Diary}
\author{Someone}
\date{}
\begin{document}
\maketitle

\include{./2013/2013}
\end{document}

Output

enter image description here

Addendum

To use orange sidebar on left instead right, the input.tex file rearranged as follows:

\usepackage[top=4cm, bottom=2cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=3cm, marginparsep=0.75cm]{geometry}

\newcommand{\mybox}[1]{%
\marginnote{{\color{red}CAUTION!}\\{#1}}
}

\newlength\sidebar
 \newlength\envrule
 \newlength\envborder
 \setlength\sidebar{1.5mm}
 \setlength\envrule{0.4pt}
 \setlength\envborder{2mm}

\makeatletter
 \long\def\fboxs#1{%
   \leavevmode
   \setbox\@tempboxa\hbox{%
     \color@begingroup
       \kern\fboxsep{#1}\kern\fboxsep
     \color@endgroup}%
   \@frames@x\relax}
 \def\frameboxs{%
   \@ifnextchar(%)
     \@framepicbox{\@ifnextchar[\@frameboxs\fboxs}}
 \def\@frameboxs[#1]{%
   \@ifnextchar[%]
     {\@iframeboxs[#1]}%
     {\@iframeboxs[#1][c]}}
 \long\def\@iframeboxs[#1][#2]#3{%
   \leavevmode
   \@begin@tempboxa\hbox{#3}%
     \setlength\@tempdima{#1}%
     \setbox\@tempboxa\hb@xt@\@tempdima
          {\kern\fboxsep\csname bm@#2\endcsname\kern\fboxsep}%
     \@frames@x{\kern-\fboxrule}%
   \@end@tempboxa}
 \def\@frames@x#1{%
   \@tempdima\fboxrule
   \advance\@tempdima\fboxsep
   \advance\@tempdima\dp\@tempboxa
   \hbox{%
     \lower\@tempdima\hbox{%
       \vbox{%
        \hrule\@height\fboxrule
       %  \hbox{%
        %  \vrule\@width\fboxrule

           #1%
           \vbox{%
             \vskip\fboxsep
             \box\@tempboxa
             \vskip\fboxsep}%
           #1%
           }\vrule\@width\fboxrule}%
         }%\hrule\@height\fboxrule}%
                          % }%
        % }%
 }
 \def\esefcolorbox#1#{\esecolor@fbox{#1}}
 \def\esecolor@fbox#1#2#3{%
   \color@b@x{\fboxsep\z@\color#1{#2}\fboxs}{\color#1{#3}}}
 \makeatother


 \definecolor{exampleborder}{HTML}{FE642E}
 \definecolor{examplebg}{HTML}{CEF6EC}
 \definecolor{statementborder}{rgb}{.9,0,0}
 \definecolor{statementbg}{rgb}{1,1,1}

 \newenvironment{eseframed}{%
   \def\FrameCommand{\fboxrule=\the\sidebar  \fboxsep=\the\envborder%
   \esefcolorbox{exampleborder}{examplebg}}%
   \MakeFramed{\FrameRestore}}%
  {\endMakeFramed}


 \newcounter{diary}
%\numberwithin{uygulama}
\renewcommand{\thediary}{\arabic{diary}}

 %%% CODE ENVIRONMENT. PUT TEXT INTO COLORED FRAME %%%
 \newenvironment{diary}[2]
 {\par\medskip\refstepcounter{diary}%
 \hbox{%
 \fboxsep=\the\sidebar\hspace{-\envborder}\hspace{-0.5\sidebar}%
 \colorbox{exampleborder}{%
 \hspace{\envborder}\footnotesize\sffamily\bfseries%
 \textcolor{white}{{#1}\ {#2}\enspace\hspace{\envborder}}
%\today
 }
 }
 \nointerlineskip\vspace{-\topsep}%
 \begin{eseframed}\noindent\ignorespaces%
 }
 {\end{eseframed}\vspace{-\baselineskip}\medskip}

And the output is as:

enter image description here

share|improve this answer
    
Nice work there! I am trying to use your code, but I get the error file ended while scanning the use of \@newenv plus you have a } missing at diary.tex at the very last line. –  Thanos Nov 14 '13 at 10:43
    
Did you test it? It throws tens of errors. –  egreg Nov 14 '13 at 11:05
    
@egreg I added {} at the end of the diary.tex but I get that i.imgur.com/T68DD2h.png It produces 30 errors indeed... –  Thanos Nov 14 '13 at 11:10
    
I updated my answer. –  ferahfeza Nov 14 '13 at 16:40
    
@ferahfeza: How can this be used with a different paper size, like a4 or b5? –  Thanos Nov 15 '13 at 16:07

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.