4

I want to write a (math-heavy) personal diary in LaTex. I thought of each entry be a section; something like

\section{Some title, 2017-01-13}

In addition, and as in a blog, I would like to categorize my entries (via a special command?) and would like LaTex to generate a ToC for every category.

E.g.

Category Calculus

Calculus, 2016-09-01 Derivatives, 2016-10-01

Category Algebra

Vectors, 2016-12-02 Matrices, 2017-01-02

How can I achieve this? I'm also grateful for pointers to similar projects (templates).

  • 1
    We already have a similar question on the site: Using LaTeX to keep a diary. Perhaps that is of some help. – Alan Munn Jan 15 '17 at 19:53
  • Thanks for the pointer; however, the linked thread does not solve the issue with creating a ToC for every category... – ClemensFMN Jan 17 '17 at 9:04
5

A proposition, with some slightly redefined \section command, getting an 2nd optional argument at the end, meant for the category -- the default value for this optional argument is Calculus here.

The ToC is generated as a separated index, which has the advantage of sorting with `makeindex.

Please note that there are no fancy decorations here for the section title etc.

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{imakeidx}

\usepackage{hyperref}

\makeindex[name=cat,title={Categories}]

\let\sectionorig\section

\AtBeginDocument{%
\RenewDocumentCommand{\section}{s+o+m+O{Calculus}}{%
  \clearpage%
  \IfBooleanTF{#1}{%
    \sectionorig*{#3}
  }{%
    \def\sectitle{#3}
    \IfValueT{#2}{%
      \def\sectitle{#2}
    }%
    \sectionorig[\sectitle]{#3}%
  }%
  \index[cat]{{\large\textbf{Category #4}\vskip0.5\baselineskip}!#3}%
  }%
}




\begin{document}

\section{Vector algebra, \today}[Linear Algebra]

\section{Calculus, 2017-01-14}


\section{Derivatives, 2017-01-13}

\section{Tangents, 2017-01-5}

\section{Matrices, 2016-12-31}[Linear Algebra]


\printindex[cat]

\end{document}

enter image description here

  • Would it be possible to index an entry under more than one category? For example, a blog post indexed under both Differential Equations and Matrix Algebra? – Bryan M-H Aug 27 '18 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.