QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2580|回复: 0
打印 上一主题 下一主题

LaTeX技巧623:两个页眉设计

[复制链接]
字体大小: 正常 放大

342

主题

41

听众

214748万

积分

升级  0%

  • TA的每日心情
    擦汗
    2015-7-24 10:40
  • 签到天数: 37 天

    [LV.5]常住居民I

    社区QQ达人 邮箱绑定达人 元老勋章 发帖功臣 新人进步奖 优秀斑竹奖 金点子奖 原创写作奖 最具活力勋章 助人为乐奖 风雨历程奖

    群组MATLAB的工程数学应用

    群组SAS公益讲座

    跳转到指定楼层
    1#
    发表于 2015-1-29 15:47 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta



      代码摘选:

      % ----------------------------------------------------------------

      % Book Class (This is a LaTeX2e document) ***********************

      % ----------------------------------------------------------------

      \documentclass[10pt,x11names,svgnames,twoside]{book}

      \usepackage{tikz}

      \usetikzlibrary{shapes.misc,calc}

      \usepackage{lipsum,fancyhdr}

      \usepackage[a4paper,left=1.2in,right=1in,top=1in,bottom=1in,headheight=\baselineskip,

      headsep=9mm,footskip=13mm,showframe,]{geometry}

      % ----------------------------------------------------------------

      \newcommand\MyColor{% % This line is from Gonzalo's answer

      \ifcase\thechapter blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi} % This line is from Gonzalo's answer

      %------------------------------------------

      \fancypagestyle{plain}{%

      %% Clear all headers and footers

      \fancyhf{}

      %% Right headers on odd pages

      \fancyhead[RO]{%

      \rotatebox{90}{

      \begin{tikzpicture}[overlay,remember picture]

      \node[fill=\MyColor,text=white,

      font=\footnotesize,

      inner ysep=12pt, inner xsep=20pt,

      rounded rectangle,anchor=east,

      at ($ (current page.north east) + (2.9cm,-0cm) + (-4*\thechapter cm,0cm) $)

      {\sffamily\itshape\small\nouppercase{\leftmark}};

      \end{tikzpicture}

      }

      }

      %% Left headers on even pages

      \fancyhead[LE]{%

      \rotatebox{90}{

      \begin{tikzpicture}[overlay,remember picture]

      \node[fill=\MyColor,text=white,

      font=\footnotesize,

      inner ysep=12pt, inner xsep=20pt,

      rounded rectangle,anchor=east,

      at ($ (current page.north west) + (4cm,0cm) + (-4*\thechapter cm,0cm) $)

      {\sffamily\itshape\small\nouppercase{\leftmark}};

      \end{tikzpicture}

      }

      }

      \renewcommand{\headrulewidth}{0pt}

      \renewcommand{\footrulewidth}{0pt}

      \fancyfoot[R]{\thepage}

      }

      % ----------------------------------------------------------------

      \pagestyle{plain}

      \renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

      \begin{document}

      %

      \chapter{First chapter}

      \lipsum[1-16]

      \cleardoublepage

      \chapter{Second chapter}

      \lipsum[1-16]

      \chapter{Third chapter}

      \lipsum[1-16]

      \chapter{Fourth chapter}

      \lipsum[1-16]

      %

      \end{document}

      \documentclass{book}

      \usepackage{background}

      \usetikzlibrary{calc}

      \usepackage{ifthen}

      \usepackage{lipsum}

      \pagestyle{plain}

      % background common settings

      \SetBgScale{1}

      \SetBgAngle{0}

      \SetBgOpacity{1}

      \SetBgContents{}

      % auxiliary counter

      \newcounter{chapshift}

      \addtocounter{chapshift}{-1}

      % the list of colors to be used (add more if needed)

      \newcommand\BoxColor{%

      \ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}

      % the main command; the mandatory argument sets the color of the vertical box

      \makeatletter

      \newcommand\ChapFrame{%

      \AddEverypageHook{%

      \ifthenelse{\isodd{\thepage}}

      {\SetBgContents{%

      \begin{tikzpicture}[overlay,remember picture]

      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=2cm,

      at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)

      {\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{%

      \raggedright\textcolor{black}{\scshape\leftmark}}}};

      \end{tikzpicture}}%

      }

      {\SetBgContents{%

      \begin{tikzpicture}[overlay,remember picture]

      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=2cm,

      at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)

      {\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{%

      \raggedright\textcolor{black}{\scshape\leftmark}}}};

      \end{tikzpicture}}

      }

      \bg@material}%

      \stepcounter{chapshift}

      }

      \makeatother

      % redefinition of \chaptermark to contain only the title

      \renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}

      \begin{document}

      \chapter[intro]{Introduction}

      \ChapFrame

      \lipsum[1-7]

      \chapter{Results}

      \ChapFrame

      \lipsum[1-7]

      \chapter{Discussion}

      \ChapFrame

      \lipsum[1-7]

      \end{document}



    扫描下方二维码,关注数学中国微信获取更多实用信息!


    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    你看得见我打在屏幕上的字,却看不到我掉在键盘上的泪
    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2025-8-16 01:54 , Processed in 0.530236 second(s), 50 queries .

    回顶部