发布时间:2012-07-04 00:55:39
文章类别:页面设置
原文地址:http://blog.sina.com.cn/s/blog_5e16f1770102ett3.html

QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载

看图说话:

image

image

选自:

http://tex.stackexchange.com/questions/48641/chapter-title-in-rotated-vertical-box-at-the-margin

代码摘选:

% ----------------------------------------------------------------
% 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,
xshift=-0mm,yshift=-32mm,text width=3cm, text height=0.4cm]
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,
xshift=41mm,yshift=-2mm,text width=3cm, text height=0.4cm]
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,
text height=4cm,align=center,anchor=north east]
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,
text height=4cm,align=center,anchor=north west]
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}


点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部