我正在浏览网页以寻找我正在编写的报告的一些设计灵感,我发现这两个标题和页码的示例位于页面的侧面而不是顶部和底部。
的封面Fogli 杂志,Salitá dei Frati 图书馆协会,可以从其网站下载:
还有一个标题页。
这里在 Bechance 上有一个类似的例子。
我对第一个特别感兴趣。有人知道如何在 LaTeX/XeLaTeX 中实现这样的页眉/页码布局吗?
我想到了一个快速而又粗暴的解决方案。
\documentclass[a4paper]{article}
\usepackage{everypage,tikz,blindtext}
% Option for title page:
\newif\ifplainst
% Clear page style:
\pagestyle{empty}
% A new(ish) section command:
\let\oldsection\section
\def\sectionname{\thetitle}
\renewcommand{\section}[1]{%
\oldsection{#1}
\renewcommand{\sectionname}{#1}
}%
% The sideways header:
\AddEverypageHook{%
\ifplainst
\tikz[remember picture,overlay]{%
% Node with the page number
\node[anchor=north,rotate=-90,yshift=-5ex] at (current page.-45)
{\thepage};
}%
\else
\tikz[remember picture,overlay]{%
% First node with the section number and name
\node[anchor=north,rotate=-90,yshift=-5ex,xshift=6ex] at (current page.45)
{\textsection \hspace{2pt} \thesection \hspace{2pt} \dots
\hspace{4pt} \sectionname};
% Second node with the pagenumber
\node[anchor=north,rotate=-90,yshift=-5ex] at (current page.-45)
{\thepage};
}%<- End of \tikz
\fi
}% <- end of \AddEverypageHook
\begin{document}
\plainsttrue
\section{Sample Section}
\Blindtext[5]
\plainstfalse
\Blindtext[2]
\end{document}
由此得出:
还有人有其他可能更好的解决方案吗?
答案1
我不太明白所需的结果是什么,但使用包应该可以实现scrlayer-scrpage
。此包使用图层定义其页面样式。因此可以定义新图层并将其添加到页面样式中。
\documentclass[a4paper
,twoside
]{article}
\usepackage{blindtext}% dummy text
\usepackage{graphicx}
\usepackage[markcase=noupper]{scrlayer-scrpage}
\automark[section]{section}
\renewcommand\sectionmarkformat{\textsection \hspace{2pt} \thesection \hspace{2pt} \dots\hspace{4pt}}
% remove the default contents of header and footer for pagestyles scrheadings and plain
\clearpairofpagestyles
% add new layers to scrheadings and plain.scrheadings (note that plain is an alias for plain.scrheadings}
\AddLayersToPageStyle{scrheadings}{margin.even,margin.odd}
\AddLayersToPageStyle{plain.scrheadings}{plain.margin.even,plain.margin.odd}
% define the new layers in the outer margin
\DeclareNewLayer[
background,
evenpage,
textarea,
addhoffset=\dimexpr-\marginparwidth-\marginparsep\relax,
width=\marginparwidth,
contents={\rotatebox{90}{%
\parbox{\layerheight}{%
\pagemark\hfill
\parbox[t]{\dimexpr\layerheight-4em\relax}{\raggedleft\headmark}%
}}}
]{margin.even}
\DeclareNewLayer[
background,
oddpage,
textarea,
addhoffset=\dimexpr\textwidth+\marginparsep\relax,
width=\marginparwidth,
contents={\hfill\rotatebox[origin=Br]{-90}{%
\parbox{\textheight}{%
\parbox[t]{10cm}{\raggedright\headmark}%
\hfill
\pagemark
}}}
]{margin.odd}
\DeclareNewLayer[
clone=margin.even,
contents={\rotatebox{90}{%
\parbox{\layerheight}{\pagemark\hfill}
}}
]{plain.margin.even}
\DeclareNewLayer[
clone=margin.odd,
contents={\hfill\rotatebox[origin=Br]{-90}{%
\parbox{\layerheight}{\hfill\pagemark}
}}
]{plain.margin.odd}
\begin{document}
\section{Sample Section}\thispagestyle{plain}
\Blindtext[10]
\end{document}