
我已使用该fancyhdr
包自定义页面的页眉。但是,当我想让页面横向显示时(通过使用该pdflscape
包),它确实会生成横向页面,但页眉位于页面的右侧(参见附图)。我正在使用article
文档类。这是我的代码:
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\sectionmark}[1]{\markboth{\thesection.\ #1}{}}
\lhead{\leftmark} %section
\rhead{\thepage} %page number
\newpage
\begin{landscape}
\subsection{asdasd}
\end{landscape}
我怎样才能将页眉移至页面顶部?
@grimler 解决了页眉旋转的问题,但现在图片无法位于中心,并且横向页面的边缘不对称
\documentclass[12pt]{article}
\usepackage[left=2cm, right=2cm, bottom=2cm, top=3cm]{geometry}
\geometry{letterpaper}
\begin{document}
\section{Nima}
\subsection{aaaaaaaaaaaaa}
\lipsum[1]
\begin{figure}[H]
\centering
\includegraphics[width=0.5\linewidth]{male.jpg}
\caption{Example of a forward looking algorithm that identifies peaks \& troughs.}
\label{fig:old_zig_1}
\end{figure}
\newpage
\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
\headwidth=\textheight
\begingroup
\vsize=\textwidth
\hsize=\textheight
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.4\linewidth]{male.jpg}
\end{center}
\caption{Example of a forward looking algorithm that identifies peaks \& troughs.}
\label{fig:old_zig_1}
\end{figure}
\endgroup
答案1
同样的疑问在横向模式下保持页眉在顶部?
@touhami 给出了一个很好的答案。不要使用景观环境,而是使用以下方法将几何图形更改为景观:
\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
然后将头部宽度设置为文本高度:
\headwidth=\textheight
现在在组内本地设置文本宽度和文本高度并编写您的景观内容:
\begingroup
\vsize=\textwidth
\hsize=\textheight
%landscape stuff
\endgroup
然后使用相同的代码改回肖像(不同之处在于头部宽度应该是文本宽度)。
完整 MWE:
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\begin{document}
\pagestyle{fancy}
\fancyhf{}
\lipsum[1]
\newpage
\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
\headwidth=\textheight
\begingroup
\vsize=\textwidth
\hsize=\textheight
\lipsum[2]
\endgroup
\newpage
\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
\headwidth=\textwidth
\lipsum[3]
\end{document}