Last active
April 14, 2025 10:54
-
-
Save lrtfm/c5de5d490039622738a719c62de3243f to your computer and use it in GitHub Desktop.
A LaTeX template for a paper with fixed baselineskip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% A LaTeX template for a paper with fixed baselineskip | |
\documentclass[a4paper,zihao=-4]{ctexart} | |
\newlength{\fixbaselineskip} | |
\setlength{\fixbaselineskip}{1.104762cm} | |
\usepackage[% | |
left=2.5cm, right=2.5cm, | |
top=4.7cm, | |
textheight=21\fixbaselineskip, | |
% bottom=1.6cm, | |
heightrounded=false, | |
showframe=false | |
]{geometry} | |
\usepackage{fancyhdr} | |
\usepackage{calc} | |
\usepackage{etoolbox} | |
\usepackage{everypage} | |
\usepackage{lastpage} | |
% \usepackage{showframe} | |
\usepackage{layout} % for command \layout and \layout* | |
\usepackage{enumitem} % for customizing list environments | |
\usepackage{tikz} | |
\usetikzlibrary{calc,arrows} | |
\usepackage{lipsum} | |
\usepackage{zhlipsum} | |
% fix the baselineskip | |
\apptocmd{\selectfont}{\setlength{\baselineskip}{\fixbaselineskip}}{}{} | |
\setlength{\topskip}{0.9cm} % move the text a little above | |
\newlength{\xtopmargin} | |
\setlength{\xtopmargin}{1in + \voffset + \topmargin + \headheight + \headsep} | |
\newlength{\xleftmargin} | |
\setlength{\xleftmargin}{1in + \hoffset + \oddsidemargin} | |
\newcommand{\plotbaselines}{% | |
\begin{tikzpicture}[remember picture, overlay, shift=(current page.north west)] | |
\foreach \i in {0,...,21} { | |
\draw[red!40, thick] | |
(\xleftmargin, - \xtopmargin - \i\fixbaselineskip) -- ++(\textwidth, 0); | |
} | |
\end{tikzpicture} | |
} | |
\ctexset{ | |
section = { | |
format = \raggedright\bf, | |
afterskip = 0pt, | |
beforeskip = 0pt | |
} | |
} | |
\parskip=0pt | |
\setlist[enumerate]{topsep=0pt, itemsep=0pt, parsep=0pt, partopsep=0pt} | |
\newcommand{\sign}{\vfill\hskip8cm \raisebox{\fixbaselineskip-\topskip}{签名:}} | |
\newcounter{namecount} | |
\newcommand{\currentnameid}{} | |
\newcommand{\currentname}{} | |
\newcommand{\setname}[1]{% | |
\ifnum\value{namecount}>0 | |
\label{lastpage\currentnameid}% | |
\newpage% | |
\setcounter{page}{1}% | |
\fi | |
\stepcounter{namecount} | |
\edef\currentnameid{\Alph{namecount}}% | |
\def\currentname{#1}% | |
} | |
\AtEndDocument{\label{lastpage\currentnameid}} | |
\pagestyle{fancy} | |
% for fancyhdr warning | |
\setlength{\headheight}{14.45398pt} % Adjust head height to avoid fancyhdr warning | |
\addtolength{\topmargin}{-2.45398pt} % Compensate for the increased head height | |
\fancyhf{} | |
\fancyhead[R]{姓名:\currentname \quad\thepage/\pageref*{lastpage\currentnameid}} | |
\renewcommand{\headrulewidth}{0pt} | |
% show the base lines | |
\AddEverypageHook{\plotbaselines} | |
\begin{document} | |
% \layout{} | |
% (1) | |
\setname{赵钱孙} | |
% make blank pages | |
\zhlipsum[1-5][name=zhufu] | |
% \foreach \i in {1,...,2} { | |
% \newpage | |
% \mbox{} | |
% } | |
\sign | |
% (2) | |
\setname{周武郑} | |
\zhlipsum[1][name=zhufu] | |
\sign | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment