2

I am trying to make a diary that will have a book-like page structure with side notes in A5/B5 paper size. I was able to create the style I want, but it can only be applied using an article documentclass.

The idea is to have a diary.tex in which there is Gonzalo Medina's code for caution side notes from create a framed environment for a margin note as well as Ferahfeza's code for Colored Boxed Diary Entries from Using LaTeX to keep a diary.

The diary.tex that works with a4paper and article is the following

%%%%%%%%%%%%%%~~~~~~~~~~Caution Side Note~~~~~~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry}

\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]}}


%%%%%%%%%%%%%%~~~~~~~~~~Colored Boxed Diary Entries~~~~~~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%


\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}
 \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}}
 }
 }
 \nointerlineskip\vspace{-\topsep}%
 \begin{eseframed}\noindent\ignorespaces%
 }
 {\end{eseframed}\vspace{-\baselineskip}\medskip}

The main.tex file is the following

\documentclass[]{article}
%\usepackage[b5paper,           %paper size
                 %hmargin=1.0cm, %horizontal margin = 1 cm on each side
                 %vmargin=1.0cm, %vertical margin = 1 cm top and bottom
%                tmargin=1.2cm, %top margin = 1.2 cm
%                bmargin=0.8cm, %bottom margin = 0.8 cm 
                 %]{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}

\input{diary}

\begin{document}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4] \caution{\lipsum[2]} \lipsum[3-5]
\end{diary}

 \begin{diary}{}{14.07.2013}
 \lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
 \end{diary}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
\end{diary}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
\end{diary}

\end{document}

I tried to use \documentclass[a5paper]{article} and \documentclass{book} but the oupput is really ugly and messed up.

enter image description here

What can be done to have a nice two-sided diary(like a book) in a5/b5 size?

  • Your textwidth is tooo large. Did you run multiple times? Are you still interested in a solution, or can we close this? – Johannes_B Nov 27 '14 at 17:58
  • @Johannes_B : Thank you very much for your comment. I run it multiple times, but it doens't work! And yes, I am still looking for a solution! – Thanos Nov 30 '14 at 13:49
  • Please see my added answer ... – Mensch Feb 13 at 22:37
1

In your file diary.tex you have used the line

\usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry}

with an wrong option textwidth=15cm, because a a5 paper can not have such a long textwidth. Simply delete that option and in the following MWE I moved the call of package geometry from diary.tex into the preamble of the file mwe.tex. To have only one file mwe.tex I moved diary.tex completly into mwe.tex ...

Please see that I added option showframe for geometry to get a visualized typing area and margins for better understanding.

Please see that I deleted your commented geometry call because it was using options not fitting your situation with the bigger space (4cm) needed for your left margin ...

With the following MWE (code changes marked with <==========)

\documentclass[a5paper]{article} % <====================================

\usepackage[% <=========================================================
  lmargin=5cm,
% textwidth=15cm,
  marginparwidth=4cm,
  showframe % <==================== to visualize typing area and margins
]{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}

%\input{diary}
%%%%%%%%%%%%%%~~~~~~~~~~Caution Side Note~~~~~~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%

%\usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry} % <===============================

\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]}}


%%%%%%%%%%%%%%~~~~~~~~~~Colored Boxed Diary Entries~~~~~~~~~%%%%%%%%%%%%%%%%%%%%%%%%%%


\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}
 \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}}
 }
 }
 \nointerlineskip\vspace{-\topsep}%
 \begin{eseframed}\noindent\ignorespaces%
 }
 {\end{eseframed}\vspace{-\baselineskip}\medskip}




\begin{document}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4] \caution{\lipsum[2]} \lipsum[3-5]
\end{diary}

 \begin{diary}{}{14.07.2013}
 \lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
 \end{diary}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
\end{diary}

\begin{diary}{}{14.07.2013}
\lipsum*[3-4]\caution{\lipsum[2]}\lipsum[3-5]
\end{diary}

\end{document}

I get the following resulting pdf file with papersize A5:

resulting first page

| improve this answer | |

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.