带边注的 A5/B5 纸张大小的书

带边注的 A5/B5 纸张大小的书

我正在尝试制作一本日记,该日记将具有类似书本的页面结构,并在 A5/B5 纸张大小下带有旁注。我能够创建我想要的样式,但它只能使用 来应用article documentclass

这个想法是,有一个diary.texGonzalo Medina 的代码警告 旁注为边注创建一个框架环境以及 Ferahfeza 的代码彩色盒装日记本使用 LaTeX 记日记

diary.tex适用于a4纸张文章以下是

%%%%%%%%%%%%%%~~~~~~~~~~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}

main.tex文件如下

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

我尝试使用\documentclass[a5paper]{article}\documentclass{book}但输出结果非常丑陋和混乱。

在此处输入图片描述

怎样才能拥有 a5/b5 尺寸的漂亮双面日记本(像书一样)?

答案1

在您的文件中,diary.tex您使用了以下行

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

使用错误的选项textwidth=15cm,因为 a5 纸张不能有这么长的文本宽度。只需删除该选项,然后在以下 MWE 中,我将包的调用移至geometry文件diary.texmwe.tex 的前言中。为了只有一个文件,mwe.tex我将其diary.tex完全移入mwe.tex...

请注意,我添加了选项showframegeometry获得可视化的打字区域和边距,以便更好地理解。

请注意,我删除了您的评论,geometry因为它使用的选项不适合您情况,左边距需要更大的空间(4厘米)...

使用以下 MWE(代码更改标有<==========

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

我得到了以下纸张尺寸为 A5 的 PDF 文件:

生成第一页

相关内容