我正在从文章中派生一个类。我的第一个任务是调整边距和宽度。我的第二个任务是在标题页顶部放置页眉。我没有单独放置每个组件,而是创建了一个要放置在标题页左上角的图形。虽然水平放置/计算按预期工作,但向页面顶部移动很麻烦。
到目前为止的课程档案
\LoadClassWithOptions{llncs}
\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}
\setlength\oddsidemargin {20mm}
\setlength\evensidemargin {20mm}
\setlength\marginparwidth {0\p@}
\setlength\hoffset {-1in}
\setlength\voffset {8mm}
\setlength\topmargin {-1in}
\setlength\headsep {0\p@}
\setlength\headheight {0\p@}
\setlength\footskip {3.8mm}
\RequirePackage{graphicx}
由于页眉应该只出现在标题页上,我认为将其与标题放在一起是有意义的。要放置标题,有一个宏\@maketitle
。我将其定义复制到我的新类文件中以进行修改。最初,标题放在环境中center
。我将页眉放在该环境之前,如下所示:
\hskip -\oddsidemargin%
\hskip -6.1925mm%
\includegraphics{my_special_header}%
使用\hskip
正好达到了我想要的效果:页眉显示在页面的左边缘。添加后,页眉显示在页面顶部 8 毫米处,即 的值\voffset
。请注意,我使用了\voffset
和\topmargin
组合,因为 的值为负数时文档无法编译\voffset
。
要将页眉移到页面顶部边缘,我\hskip
在语句前面添加了
\vspace*{-\voffset}%
... 这并没有产生预期的结果。此行将页眉向上移动 3 毫米。要将其移位整整 8 毫米,即让页眉出现在页面的左上角,我必须
\vspace*{-12.575mm}%
这对我来说完全不是直观的。我通过反复试验才得到这个值。
LaTeX 为何会有这样的表现?
以下是我的完整课程文件(已改编)\@maketitle
:
(我把\rule
includegraphics改成了a)
基类.cls:
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{baseclass}[2010/07/12 v2.17
^^J LaTeX document class for Lecture Notes in Computer Science]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClassWithOptions{article}
\RequirePackage{multicol} % needed for the list of participants, index
\RequirePackage{aliascnt}
\RequirePackage{graphicx}
\RequirePackage{lastpage}
\newcommand{\bibtexstyle}{splncs03} % Springer Style
\endinput
科技课堂
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{techclass}[2015/02/08 v0.1
^^J LaTeX document class for technical papers]
\LoadClassWithOptions{baseclass}
\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}
\renewcommand\@pnumwidth{2em}
\renewcommand\@tocrmarg{3.5em}
\setlength\oddsidemargin {20mm}
\setlength\evensidemargin {20mm}
\setlength\marginparwidth {0\p@}
\setlength\voffset {-1in}
\setlength\topmargin {8mm}
\setlength\headsep {0\p@}
\setlength\headheight {0\p@}
\setlength\footskip {3.8mm}
\setlength\footnotesep{7.7\p@}
\setlength\textfloatsep{8mm\@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {8mm\@plus 2\p@ \@minus 2\p@}
\setlength\hoffset {-1in}
\def\@maketitle{\newpage
\markboth{}{}%
\def\lastand{\ifnum\value{@inst}=2\relax
\unskip{} \andname\
\else
\unskip \lastandname\
\fi}%
\def\and{\stepcounter{@auth}\relax
\ifnum\value{@auth}=\value{@inst}%
\lastand
\else
\unskip,
\fi}%
\vspace*{-12.575mm}%
\hskip -\oddsidemargin%
\hskip -6.1925mm
%\includegraphics{complete_header}%
\rule{\textwidth}{3cm}
\begin{center}%
\let\newline\\
{\Large \bfseries\boldmath
\pretolerance=10000
\@title \par}\vskip .8cm
{\lineskip .5em
\noindent\ignorespaces
\@author\vskip.35cm}
%{\small\institutename}
\end{center}%
}
\pagestyle{plain}
\let\pagestyle\relax
\def\strpage{Page}
\def\strof{of}
\def\@oddfoot{\hfil\strpage~\thepage~\strof~\pageref{LastPage}}
\let\@evenfoot\@oddfoot
\endinput
以下是一个相当 MWE:
\documentclass[12pt,a4paper]{techclass}
\begin{document}%
\title{Hello World}
\author{%
Foo B. Baz
}
\maketitle
\begin{abstract}
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
\end{abstract}
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three
\end{document}
我的工作文件:
\documentclass[12pt,a4paper]{techclass}
\newcommand{\mytitle}{How to use this template}
\newcommand{\pdfmetainfo}{My Name Removed}
\usepackage{ifpdf}
\usepackage[english]{babel}
\usepackage{paralist}
\usepackage{tabularx}
\usepackage{layout}
\usepackage{ifluatex}
\ifluatex
\usepackage[latin1]{luainputenc}
\else
\usepackage[latin1]{inputenc}
\fi
\ifpdf
\pdfcompresslevel=9
\usepackage{hyperref}
\hypersetup{ a4paper=true,
plainpages=false,
pdftex=true,
hyperindex=true,
bookmarks=true,
bookmarksopen=true,
bookmarksnumbered=true,
pdfauthor={\pdfmetainfo},
pdftitle={\mytitle}
}
\fi
\newcommand{\bibtexinputfiles}{paper}
\newcommand{\docbegin}[0]{%
\begin{document}%
}
\newcommand{\mybibliography}[0]{%
\ifpdf%
\pdfbookmark[0]{Bibliography}{bibphy}%
\fi%
\bibliographystyle{\bibtexstyle}%
\bibliography{\bibtexinputfiles}%
}
\newcommand{\docend}[0]{%
\end{document}
}
\docbegin
\title{\mytitle}
\author{%
My Name Removed
}
\maketitle
\begin{abstract}
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
one two three one two three one two three one two three one two three
\end{abstract}
\nocite{*}
\mybibliography
\docend
答案1
这会将规则置于顶角。
我添加它\noindent
以使其不向右移动,删除“通过眼睛”的垂直调整并\vspace*{-\dimexpr\topskip+\topmargin+\lineskip\relax}%
在规则之前添加了一个负空间。
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{techclass}[2015/02/08 v0.1
^^J LaTeX document class for technical papers]
\LoadClassWithOptions{baseclass}
\setlength{\textwidth}{170mm}
\setlength{\textheight}{270.6mm}
\renewcommand\@pnumwidth{2em}
\renewcommand\@tocrmarg{3.5em}
\setlength\oddsidemargin {20mm}
\setlength\evensidemargin {20mm}
\setlength\marginparwidth {0\p@}
\setlength\voffset {-1in}
%\setlength\topmargin {8mm}
\setlength\headsep {0\p@}
\setlength\headheight {0\p@}
\setlength\footskip {3.8mm}
\setlength\footnotesep{7.7\p@}
\setlength\textfloatsep{8mm\@plus 2\p@ \@minus 4\p@}
\setlength\intextsep {8mm\@plus 2\p@ \@minus 2\p@}
\setlength\hoffset {-1in}
\def\@maketitle{\newpage
\markboth{}{}%
\def\lastand{\ifnum\value{@inst}=2\relax
\unskip{} \andname\
\else
\unskip \lastandname\
\fi}%
\def\and{\stepcounter{@auth}\relax
\ifnum\value{@auth}=\value{@inst}%
\lastand
\else
\unskip,
\fi}%
\vspace*{-\dimexpr\topskip+\topmargin+\lineskip\relax}%
\noindent\hskip -\oddsidemargin%
% \hskip -6.1925mm
%\includegraphics{complete_header}%
\rule{\textwidth}{3cm}
\begin{center}%
\let\newline\\
{\Large \bfseries\boldmath
\pretolerance=10000
\@title \par}\vskip .8cm
{\lineskip .5em
\noindent\ignorespaces
\@author\vskip.35cm}
%{\small\institutename}
\end{center}%
}
\pagestyle{plain}
\let\pagestyle\relax
\def\strpage{Page}
\def\strof{of}
\def\@oddfoot{\hfil\strpage~\thepage~\strof~\pageref{LastPage}}
\let\@evenfoot\@oddfoot
\endinput
答案2
代替
\setlength\voffset {8mm}
\setlength\topmargin {-1in}
经过
\setlength\voffset {8mm}
\setlength\topmargin {-1in}
\addtolength\topmargin {-8mm}
在你的位置我永远不会改变 \voffset 和 \hoffset 你可以尝试
\setlength\topmargin {-1in}
\addtolength\topmargin {+-something}
\setlength\oddsidemargin {-1in}
\setlength\evensidemargin {-1}
\addtolength\oddsidemargin {+-something}
\addtolength\evensidemargin {+-something}