我的页面如下所示:
我想要做的是,在此图像的黑色部分添加一个标题:
这些是我已经使用的设置:
\documentclass[letter, 10pt]{report}\normalsize
\usepackage{amsmath,utopia}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{epsfig}
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{setspace}
\usepackage{footnote}
\usepackage{rotating}
\usepackage{needspace}
\makesavenoteenv{tabular}
\textwidth 7.5in
\addtolength{\oddsidemargin}{-0.75in}
\textheight 9.5in
\pagestyle{plain}
\addtolength{\topmargin}{-0.75in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.73cm}
\topskip 0in
\usepackage{tabularx}
\usepackage{fancybox}
\newenvironment{boxedlaw}[1]
{\begin{Sbox}\begin{minipage}{#1}\centering}
{\end{minipage}\end{Sbox}\begin{center}\fbox{\TheSbox}\end{center}}
\usepackage{cutwin}
\opencutright
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{brown}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=3pt,rounded corners=0pt]
($ (current page.north west) + (0.4in,-0.4in) $)
rectangle
($ (current page.south east) + (-0.4in,0.4in) $);
\end{tikzpicture}
}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{mycolor}{HTML}{F8E0E0}
\titleformat{\chapter}[display]
{\normalfont\bfseries\LARGE}
{\chaptertitlename~\thechapter}{0.5pc}
{{\color{brown}\titlerule[2pt]}\vspace{0.1pc}\MakeUppercase}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\bfseries\LARGE}{}{0.5pc}
{\MakeUppercase}
页眉将是一些静态文本。不是章节名称或页码。但是我希望它从我想要的点开始。也就是说,我不希望该页眉出现在前几页。我希望它出现在之后的每一页上。有没有简单的方法可以做到这一点?
答案1
在这里我想提出另一种解决方案,使用标题包;基本思想是定义一种新的页面样式,我称之为special
;使用\pagestyle{special}
这种新的页面样式可以激活;由于您还想在某些章节的第一页中包含特殊文本,因此还需要重新定义普通样式。使用\begingroup
,,\endgroup
可以将更改保持在本地(因此您可以将新样式仅应用于某些页面)。代码:
\documentclass[letterpaper, 10pt]{report}
\usepackage{amsmath,utopia}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{epsfig}
\usepackage[hidelinks]{hyperref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{setspace}
\usepackage{footnote}
\usepackage{rotating}
\usepackage{needspace}
\makesavenoteenv{tabular}
\textwidth 7.5in
\addtolength{\oddsidemargin}{-0.75in}
\textheight 9.5in
\pagestyle{plain}
\addtolength{\topmargin}{-0.75in}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.73cm}
\topskip 0in
\usepackage{tabularx}
\usepackage{fancybox}
\newenvironment{boxedlaw}[1]
{\begin{Sbox}\begin{minipage}{#1}\centering}
{\end{minipage}\end{Sbox}\begin{center}\fbox{\TheSbox}\end{center}}
\usepackage{cutwin}
\opencutright
\usepackage{background}
\usepackage{lipsum}
\usetikzlibrary{calc}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{brown}
\SetBgContents{
\begin{tikzpicture}[overlay,remember picture]
\draw [line width=3pt,rounded corners=0pt]
($ (current page.north west) + (0.4in,-0.4in) $)
rectangle
($ (current page.south east) + (-0.4in,0.4in) $);
\end{tikzpicture}
}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{mycolor}{HTML}{F8E0E0}
\titleformat{\chapter}[display]
{\normalfont\bfseries\LARGE}
{\chaptertitlename~\thechapter}{0.5pc}
{{\color{brown}\titlerule[2pt]}\vspace{0.1pc}\MakeUppercase}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\bfseries\LARGE}{}{0.5pc}
{\MakeUppercase}
\usepackage{lipsum}% just for the example
\usepackage{titleps}
% command to store the fixed text that will go in the header
\newcommand\SpecialText{\raisebox{-1em}{Some fixed text}}
% definition of the new special page style to include the fixed text
\newpagestyle{special}
{\sethead{}{}{\SpecialText}\setfoot{}{\thepage}{}}
\begin{document}
\begingroup% to keep the change local
\pagestyle{special}
% since the first page of a chapter internally uses the plain page style
% we locally redefine this style to include the fixed text
\renewpagestyle{plain}
{\sethead{}{}{\SpecialText}\setfoot{}{\thepage}{}}
\chapter{Test Chapter}
\lipsum[1-20]
\endgroup% to keep the change local
\chapter{Test Chapter}
\lipsum[1-20]
\end{document}
下图显示了章节第一页中的特殊文本:
如果要将special
样式应用于与章节首页不同的单个页面,只需调用
\thispagestyle{special}
在该页面中的某处材料中。
答案2
您的代码不完整且不精简。但是,可以实现所请求的功能fancyhdr
:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum} %<-----provides dummy text, remove in your file
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,showframe]{geometry} % <-----remove showframe and alter other things in your file
%---------------------------------------------
\fancypagestyle{mystyle}{%
\fancyhf{} % Clear all headers and footers first
\fancyhead[L]{}
\fancyhead[R]{%
\begin{tikzpicture}[remember picture,overlay]
\node[draw=brown,very thick,outer color=magenta!30,inner color=white, rectangle, rounded corners=.3cm] at ([xshift=-4.5cm,yshift=-2cm]current page.north east) {My text comes here};
\end{tikzpicture}
}%
%\setlength{\headsep}{1.1in} % if needed you can change this value
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}%
%Change the values in xshift and yshift as per your needs
%---------------------------------------------
\begin{document}
\lipsum[1-5]
\newpage
\pagestyle{mystyle}
\lipsum[6-8]
\end{document}
没有页眉的页面:
带页眉的页面:
您可以调整此样式以适合您的文本和品味。