Using LaTeX to keep a diary

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


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

Tags:

Packages