I am trying to make a diary that will have the following format
- Each entry will be inside a colored box
- Each entry will have a title with the date and an optional title
- I want the possibility to add notes on the side(preferably at the right one) in a specific line of an entry. The notes will be on a seperate colored box.
I searched the tex.se
and found two codes to achieve this. The first one comes from Gonzalo Medina's answer on create a framed environment for a margin note
His way inputs a note on the left side and I believe it would be better if the notes were on right side.
For 1 and 2, I believe that ferahfeza gave a prety answer on using latex to keep a diary however there are some points that are not working because he is probably missing a lot of code.
The idea is to have a diary.tex
(that contains the definition of a newenvironment
) file which will be inputed in a main file.
My final output would be a combination of those two
My code is
diary.tex
\newcounter{diary}
\renewcommand{\thediary}{\arabic{diary}}
\newenvironment{diary}[2]
{\par\medskip\refstepcounter{diary}%
\hbox{%
\fboxsep=\the\sidebar\hspace{-\envborder}\hspace{-.5\sidebar}%
\colorbox{orange}{%
\hspace{\envborder}\footnotesize\sffamily\bfseries%
\textcolor{white}{{#1}\ {#2}\enspace\thediary\hspace{\envborder}}
%\today % Print date in header of frame
}}}{\vspace{0.5cm}}
The main file
is the following
\documentclass{article}
\usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{ragged2e}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{marginnote}
\usetikzlibrary{calc}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{framed}
\usepackage{datetime}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\reversemarginpar
\newsavebox\mybox
\newlength\BoxHt
\newcommand\caution[2][-2.2\baselineskip]{%
\begin{lrbox}{\mybox}
\parbox{\marginparwidth}{#2}
\end{lrbox}%
\settoheight\BoxHt{\usebox\mybox}%
\raisebox{\BoxHt}[0pt][0pt]{\marginnote{%
\begin{mdframed}[
userdefinedwidth=\marginparwidth,
innerleftmargin=3pt,
innerrightmargin=3pt,
linecolor=BrickRed,
frametitle=\colorbox{white}{\space Caution\space},
frametitlefont=\color{BrickRed}\sffamily,
innertopmargin=10pt,
frametitleaboveskip=-\ht\strutbox,
frametitlebelowskip=-\ht\strutbox,
frametitlealignment=\raggedright,
singleextra={\fill[BrickRed] let \p1=(P), \p2=(O) in
( $ (P|-0,0.5*\y2+0.5*\y1) + (0,-4pt) $ ) -- +(4pt,4pt) -- +(0,8pt) -- cycle;}
]\RaggedRight\small#2\end{mdframed}}[#1]}}
\input{diary}
\begin{document}
\begin{diary}{}{14.07.2013}
\lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
\end{diary}
Some test text\caution{Some text goes here just to illustrate the command}
\lipsum[4-5].\caution{Not forget to do this} This is a line that really needs some caution. But now it's time to move on to the next paragraph. \lipsum[1]
\end{document}
My output is the following
How to achieve the desired output?
EDIT
I tried to achieve the colored background using mdframed
in a new command, \note
with 3 arguments. The new diary.tex
is
\mdfdefinestyle{MyFrameBlue}{%
linecolor=blue!20!white,
outerlinewidth=0pt,
roundcorner=0pt,
innertopmargin=-15pt,
innerbottommargin=-5pt,
innerrightmargin=0pt,
innerleftmargin=0pt,
backgroundcolor=blue!20!white}
\newcounter{diary}
\renewcommand{\thediary}{\arabic{diary}}
\newenvironment{diary}[2]
{\par\medskip\refstepcounter{diary}%
\hbox{%
\setlength{\fboxsep}{5pt}
\colorbox{orange}{%
\hspace{2pt}\footnotesize\sffamily\bfseries%
\textcolor{white}{\thediary. \ {#1}\ {#2}\enspace\hspace{2pt}}
}}}{\vspace{0.5cm}}
\newcommand{\note}[3]{\begin{mdframed}[style=MyFrameBlue]
\begin{diary}{#1}{#2}{\vspace{0.5cm} #3}\end{diary}
\end{mdframed}
}
The thing is that when I use \caution{}
inside the diary
environment, the background color is adopted.
\note{}{14.11.2013}{This is the \caution{Watch the traps!} first note}
Best Answer
After ferahfeza updated his answer on using latex to keep a diary the
diary.tex
is updated like thatdiary.tex
In the
main.tex
Gonzalo Medina's code will be added, that will give the sidenotes with the pointing arrow, inside a colored box.The output is