tikz设计章节带图样式 - Eufisky - The lost book
设计一个章节样式
一个论文的章节样式设计

tikz设计章节带图样式

Eufisky posted @ 2014年6月19日 14:48 in LaTeX with tags LaTeX 章节设计 , 1191 阅读

下面的章节设计中各章均有自己的特色,并且可以自己定义章节图,效果图如下:

chapstyle

代码实现:

 

\documentclass[12pt,twoside,letterpaper]{report}

\usepackage[text={4.95in,7.5in},centering,bottom=1.5in,showframe]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{calc}
\usepackage[explicit]{titlesec}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usepackage{amsmath,amssymb}
\usepackage{tikzpagenodes}

\usepackage{anyfontsize}

\usetikzlibrary{calc,positioning}

\setlength{\oddsidemargin}{-0.25in}
\setlength{\evensidemargin}{1.75in}

\newcommand{\chapterfont}{%
\fontencoding{T1}
\fontfamily{ppl}
\fontseries{m}
\fontshape{n}
\fontsize{26}{28}\selectfont}

\newcommand{\chapternumfont}{%
\fontencoding{T1}
\fontfamily{ppl}
\fontseries{m}
\fontshape{n}
\fontsize{60}{60}\selectfont}

\newcommand{\chapterpicture}{%
\ifodd\thepage
\begin{tikzpicture}[remember picture, overlay, outer sep=0pt,inner sep=0pt]
\node[anchor=north west] at (current page marginpar area.north west) {\includegraphics[height=\textheight,width=\marginparwidth,keepaspectratio]{figure}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture, overlay, outer sep=0pt,inner sep=0pt]
\node[anchor=north east] at (current page marginpar area.north east) {\includegraphics[height=\textheight,width=\marginparwidth,keepaspectratio]{figure}};
\end{tikzpicture}
\fi}

%-------------------------------------------------------------------------
% Chapter Style
%-------------------------------------------------------------------------
\titleformat{\chapter}[display]
{\chapterfont}
{
\ifodd\thepage
\begin{tikzpicture}[overlay, remember picture]
\coordinate (aux1) at ($(current page.north east)-(0,10pt)$);
\coordinate (aux2) at ($(current page text area.east)+(\marginparsep,0)$);
\coordinate (aux3) at (aux2|-aux1);
\coordinate (aux4) at ($(current page marginpar area.north west)!0.5!(current page marginpar area.north east)$);
\path[fill=cyan] (aux3) rectangle (current page.north east) node [midway] (barabove) {};
\node[text=cyan,font=\chapternumfont,yshift=3cm] at (aux4) (chapnum) {\thechapter};
\node[cyan,outer sep=0pt,inner sep=0pt] (vline) at (aux3|-chapnum) {$\left|\vphantom{\text{\chapternumfont 1}}\right.$};
\end{tikzpicture}%
\else
\begin{tikzpicture}[overlay, remember picture]
\coordinate (aux1) at ($(current page.north west)-(0,10pt)$);
\coordinate (aux2) at ($(current page text area.west)-(\marginparsep,0)$);
\coordinate (aux3) at (current page.north west-|aux2);
\coordinate (aux4) at ($(current page marginpar area.north west)!0.5!(current page marginpar area.north east)$);
\path[fill=magenta] (aux1) rectangle (aux3) node [midway] (barabove) {};
\node[text=magenta,font=\chapternumfont,yshift=3cm] at (aux4) (chapnum) {\thechapter};
\node[magenta,outer sep=0pt,inner sep=0pt] (vline) at (aux3|-chapnum) {$\left|\vphantom{\text{\chapternumfont 1}}\right.$};
\end{tikzpicture}%
\fi
}
{-2.125in}
{
\begin{tikzpicture}[overlay, remember picture]
\node [align=left,text width=\textwidth,anchor=west] at (current page text area.west|-chapnum) {#1};
\end{tikzpicture}
}
[\vspace*{.35in}]
%-------------------------------------------------------------------------
% Chapter Page Header/Footer
%-------------------------------------------------------------------------
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyfoot[RO]{\thepage$|$}
\fancyfoot[LE]{$|$\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
%-------------------------------------------------------------------------
% Header/Footer Page Styles
%-------------------------------------------------------------------------
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyfoot[RO]{\thepage$|$}
\fancyfoot[LE]{$|$\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\pagestyle{fancy}

\begin{document}
\chapter{L'Hopitals Rule}
test\footnote{test}\chapterpicture
\lipsum[1-2]

\chapter{Descartes Rule of Signs}\chapterpicture
\lipsum[1-2]

\chapter{Mean Value Theorem and\\ Intermediate Value Theorem}
\lipsum[1-2]

\setcounter{chapter}{10}
\chapter{Other test}\chapterpicture
\lipsum[1-2]

\setcounter{chapter}{100}
\chapter{Other test}\chapterpicture
\lipsum[1-2]

\end{document}

选自:http://tex.stackexchange.com/questions/113128/code-improvement-and-suggestions-in-template


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter