20

I'd like to collect all my old private email correspondences in a LaTeX document. The document should become a kind of "diary". (I also want to bind it to a book someday.)

So what I want to create should basically look like this:

\documentclass{myemailchronicle}

\begin{document}

\begin{conversation}{NameOfConversationalPartner}{EmailAddressOfConversationalPartner}{SubjectOfThisConversation}

\partner{DateAndTime}{%
Dear Max,
what an outstanding party last week, (...)
Yours Kate
}

\me{AnotherDateAndTime}{%
Hello Kate,
oh yeah it was SO GREAT, (...)
See you, Max
}

%Some more "\partner"s and "\me"s

\end{conversation}

%More conversations similar to the one shown above

\end{document}

Now, I don't have any experience with creating things like document classes or packages. I just don't know where to start...

What do you think is the best way to realize the things I want? Is there a more simple way, without using an own document class?

DJP
  • 12,451
MaxD
  • 1,137

1 Answers1

22

I don't think you need a new class here; you can use one of the standard classes (article, for example) and define your environment and commands with the help of some packages.

Here's one possibility using the tcolorbox package to define some framed boxes for the speakers (the partner and you); the conversation environment and the \partner and \me commands act as requested:

\documentclass{article}
\usepackage[a5paper]{geometry}% paper size just for the example
\usepackage[dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage{lipsum}% just to generate text for the example
\tcbuselibrary{most}

\newcommand\cpartner{}

\newenvironment{conversation}[3]
  {\clearpage%
  \noindent\parbox{\linewidth}{%
    \gdef\cpartner{#1}%
    \centering
    {\Large\textsc{#1}}\par{\large\texttt{#2}\par#3\par}}%
  \par\nobreak
  }
  {\par\bigskip}

\newtcolorbox{partn}[1][]{%
  breakable,
  enhanced,
  colback=white,
  title=\parbox{\linewidth}{\cpartner\par#1},
  coltitle=black,
  colframe=MidnightBlue!60,
  colbacktitle=MidnightBlue!20,
  before=\vskip20pt\noindent
}

\newtcolorbox{mebox}[1]{%
  breakable,
  enhanced,
  colback=white,
  title=Reply on #1,
  coltitle=black,
  colframe=Maroon!50,
  colbacktitle=Maroon!20,
}

\newcommand\partner[2][]{%
  \begin{partn}[#1]#2\end{partn}}

\newcommand\me[2]{%
  \begin{mebox}{#1}#2\end{mebox}}

\begin{document}

\begin{conversation}{Kate Johnson}{kjohnson@gmail.com}{Birthday party}
\partner[28 August 1999]{\lipsum[2]\lipsum[4]}
\me{29 August 1999}{\lipsum[4]}
\partner[31 August 1999]{\lipsum[4]}
\me{2 September 1999}{\lipsum[4]}
\end{conversation}

\begin{conversation}{Liz Taylor}{ltaylor@gmail.com}{Resignation}
\partner[28 August 1999]{Some short message}
\me{29 August 1999}{A reply}
\partner[31 August 1999]{Some short message}
\me{2 September 1999}{A reply}
\end{conversation}

\end{document}

enter image description here

Another, more sober, alternative. In this approach, a List of all Conversations (similar to a table of contents) will be automatically produced; each entry will have the name of the partner and the topic of the conversation; colors different from black were suppressed:

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{tcolorbox}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{lipsum}
\tcbuselibrary{most}

\renewcommand\thesection{}
\titleformat{\section}
  {\normalfont\Large\centering}{}{0em}{#1}
\newcommand\sectionbreak{\clearpage}

\newcommand\cpartner{}

\newenvironment{conversation}[3]
  {\gdef\cpartner{#1}%
  \section[\textsc{#1}~(#3)]{\textsc{#1}\\\texttt{#2}\\#3}
  }
  {\par}

\newtcolorbox{partn}[1][]{%
  breakable,
  enhanced,
  colback=white,
  arc=0pt,
  outer arc=0pt,
  title=\parbox{\linewidth}{\cpartner\par#1},
  coltitle=black,
  colframe=black,
  boxrule=0.8pt,
  colbacktitle=white,
  before=\vskip20pt\noindent
}

\newtcolorbox{mebox}[1]{%
  breakable,
  enhanced,
  arc=0pt,
  outer arc=0pt,
  colback=white,
  title=Reply on #1,
  coltitle=black,
  colframe=black,
  boxrule=0.8pt,
  colbacktitle=white,
}

\newcommand\partner[2][]{%
  \begin{partn}[#1]#2\end{partn}}

\newcommand\me[2]{%
  \begin{mebox}{#1}#2\end{mebox}}

\renewcommand\contentsname{Conversations}
\titlecontents{section}[0em]
  {}
  {\contentslabel{0em}}
  {}
  {\titlerule*[1000pc]{.}\contentspage}

\begin{document}

\tableofcontents

\begin{conversation}{Kate Johnson}{kjohnson@gmail.com}{Birthday party}
\partner[28 August 1999]{\lipsum[2]}
\me{29 August 1999}{\lipsum[2-3]}
\partner[31 August 1999]{\lipsum[4]}
\me{2 September 1999}{\lipsum[4]}
\end{conversation}

\begin{conversation}{Liz Taylor}{ltaylor@gmail.com}{Resignation}
\partner[28 August 1999]{Some short message}
\me{29 August 1999}{A reply}
\partner[31 August 1999]{Some short message}
\me{2 September 1999}{A reply}
\end{conversation}

\begin{conversation}{Marcus Rump}{mrump@gmail.com}{Interesting offer}
\partner[28 August 1999]{Some short message}
\me{29 August 1999}{A reply}
\partner[31 August 1999]{Some short message}
\me{2 September 1999}{A reply}
\end{conversation}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Wow, what a quick and useful answer, I can't thank you enough! – MaxD Feb 08 '14 at 21:19
  • 1
    @MaxD Glad I could help! I've updated my answer with a variation of the initial proposal: no colors now (except black), and the possibility of a List of conversations automatically generated. – Gonzalo Medina Feb 08 '14 at 23:10
  • Wow, neat! If you end up using this with an automated script, I'd love to see how you do it. – bright-star Feb 09 '14 at 04:13
  • @GonzaloMedina UNBELIEVABLE! I thought about adding a table of contents by myself, without knowing how to do this, of course. And as I open the question today, it's already there. Thanks, thats so great! – MaxD Feb 09 '14 at 12:08
  • @TrevorAlexander Great idea, but unfortunately I don't have any experience with scripts as well. As in my case there are not VERY many conversations (about 100-200, I'm guessing), I think it's also possible to do it manually by copy-and-paste. – MaxD Feb 09 '14 at 12:08
  • @GonzaloMedina: What do you suggest if the consversation is nested, for example you asked something, your partner forwarded your message to third person adding some refinements of your questions, received and answer and forwarded it to you again together with some additional comments. – student Nov 08 '18 at 08:03