我想将我所有的旧私人电子邮件通信都收集到一个 LaTeX 文档中。该文档应该成为一种“日记”。(我也想有一天将它装订成书。)
所以我想要创建的内容基本上应该是这样的:
\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}
现在,我没有任何创建文档类或包之类的东西的经验。我只是不知道从哪里开始……
您认为实现我想要的东西的最佳方法是什么?有没有更简单的方法,而不使用自己的文档类?
答案1
我认为您这里不需要一个新类;您可以使用其中一个标准类(article
例如),并在某些包的帮助下定义您的环境和命令。
以下是使用tcolorbox
包为发言者(合作伙伴和您)定义一些框架;环境conversation
和\partner
命令\me
按要求行事:
\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}{[email protected]}{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}{[email protected]}{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}
另一个更为冷静的替代方案。在这种方法中,将自动生成所有对话的列表(类似于目录);每个条目将包含合作伙伴的姓名和对话主题;除黑色以外的颜色被抑制:
\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}{[email protected]}{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}{[email protected]}{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}{[email protected]}{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}