在之前的两个月,补充了不少排版上的知识,是时候发挥一下了。把原先写程序文档的模板加以改进。成果如下。
usepackage{graphicx}
usepackage{indentfirst}
usepackage[usenames,dvipsnames]{color}
usepackage{fancyvrb} % for verbatim
usepackage{fancyhdr}
usepackage{listings}
usepackage[sf]{titlesec}
usepackage{titletoc}
usepackage[boldfont,slantfont,CJKnumber]{xeCJK}
usepackage{xcolor} % 使用颜色宏包
usepackage{color}
usepackage{amsmath, amsfonts, epsfig, xspace}
usepackage{algorithm,algorithmic}
usepackage[normal,tight,center]{subfigure}
usepackage{graphicx}
usepackage{booktabs}
usepackage{longtable}
usepackage{array}
usepackage{multicol}
usepackage{colortbl}
definecolor{steelblue}{rgb}{.275,.51,.71}
definecolor{lpink}{rgb}{.991,.711,.754}
definecolor{mygray}{gray}{0.92}
definecolor{darkblue}{rgb}{0,0,.5}
definecolor{darkgreen}{rgb}{0,.39,0}
definecolor{hgray}{gray}{.5}
definecolor{lgray}{gray}{.8}
usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref} % for links and anchors
setCJKmainfont[BoldFont=Adobe Heiti Std]{Adobe Song Std} % 设置默认的中文字体
setCJKfamilyfont{kai}{Adobe Kaiti Std}
newcommand{kai}{CJKfamily{kai}}
newcommand{sectionname}{第CJKnumber{thesection}章}
newcommand{myheader}[1]{textcolor{darkblue}{#1}}
defprojectName{Enhance2web20}
renewcommandcontentsname{目录}
special{ pdf: bgcolor [ 1.00 0.98 0.95 ] }
linespread{1.382}
pagestyle{fancy}
makeatletter
fancyhf{}
lhead{textcolor{hgray}@title}
rhead{textcolor{hgray}leftmark}
makeatother
makeatletter
renewcommand{maketitle}{
begin{titlepage}%
letfootnotesizesmall
letfootnoterulerelax
parindent z@
reset@font
vskip 10p@
hbox{mbox{%
hspace{4pt}%
fbox{includegraphics[width=6em]{../logo.png}}%
hspace{4pt}
}%
vrule depth 0.8textheight%
mbox{hspace{2em}}
vtop{% %%%%%%%%%%%%%%%%%%
vskip 40p@
begin{flushleft}
Large projectName par
end{flushleft}
vskip 80p@
begin{flushleft}
textcolor{steelblue}{ fontsize{36}{20pt} bfseries kai @title }par
end{flushleft}
}
}
rightline{By @author}
end{titlepage}%
}
makeatother
titleformat{section}[hang]{LARGEsfkai}
{myheadersectionname}
{1em}
{myheader}[color{steelblue}{titlerule}]
titleformat{subsection}[hang]{Largesfkai}
{myheaderthesubsection}
{1em}
{myheader}
titleformat{subsubsection}[hang]{largesfkai}
{myheaderthesubsubsection}
{1em}
{myheader}
titlecontents{section}
[2em]{largesfkaiaddvspace{-0.1em}}
{thecontentslabelquad}
%% {hspace*{-2.3em}}
{}
{titlerule*[0.8pc]{.}contentspage}
titlecontents{subsection}
[4em]{smalladdvspace{-0.2em}}
{thecontentslabelquad}
%% {hspace*{-2.3em}}
{}
{titlerule*[0.8pc]{.}contentspage}
titlecontents{subsubsection}
[6em]{smalladdvspace{-0.2em}}
{thecontentslabelquad}
%% {hspace*{-2.3em}}
{}
{titlerule*[0.8pc]{.}contentspage}
lstset{
keywordstyle=color{blue!70}, commentstyle=color{red!50!green!50!blue!50},
frame=shadowbox,
rulesepcolor=color{red!20!green!20!blue!20}
}
lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
lstset{extendedchars=false}
% lstset{ xleftmargin=2em,xrightmargin=2em, aboveskip=1em}
只要把最上面的代码,保存成J_sty_zh.tex,再你的代码中input进去就好了。示例如下:
documentclass[12pt,a4paper,titlepage]{article}
input{J_sty_zh.tex}%% 关键
title{架构说明书}
author{htmladdnormallink{tt Jerry Mouse}{http://jerrymouse.org.cn/}}
date{today}
begin{document}
maketitle
tableofcontents
clearpage
section{引言}
subsection{编写目的}
XXX
end{document}