我如何使中心页脚集中并使右页脚右对齐?
梅威瑟:
\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage{gensymb}
\usepackage{tabularx,array,booktabs} % for stretching tables to page width
\newcolumntype{Y}{>{\centering\arraybackslash}X} % for centering tables in tabularx
\newcolumntype{N}{@{}m{0pt}@{}} % for vertical space in tabularx
\newcommand{\heading}[1]{\bfseries\begin{tabular}{@{}c@{}} #1 \end{tabular}} % for a header in tables
\def\tabularxcolumn#1{m{#1}} % for vertically centering text in tables
\usepackage{float}
\usepackage[landscape]{geometry}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{pstricks-add} % for geogebra
\usepackage{amsmath,amssymb}
\usepackage{fancyhdr}
\usepackage{tcolorbox}% for framed rounded boxes
\tcbset{colframe=black,colback=white,colupper=black,
fonttitle=\bfseries,nobeforeafter,center title,size=small}
\tcbuselibrary{breakable}
\usepackage{framed}% for framed standard boxes
\pagestyle{fancy}
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt}
\lfoot{Left footer}
\cfoot{Center footer}
\rfoot{Right footer}
\linespread{1.2}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\par\medskip}
\newenvironment{cframed}
{
\begin{framed}\begin{center}
}
{
\end{center}\end{framed}
}
% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
}
% Turn off header and footer
%\pagestyle{empty}
% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%x
{\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
{-1explus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%
{\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{1ex plus .2ex}%
{\normalfont\small\bfseries}}
\makeatother
% Define BibTeX command
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
% Don't print section numbers
%\setcounter{secnumdepth}{0}
\setcounter{secnumdepth}{1}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}
% -----------------------------------------------------------------------
\begin{document}
\raggedright
\footnotesize
\begin{multicols}{3}
% multicol parameters
% These lengths are set only within the two main columns
\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\end{multicols}
\end{document}
答案1
您所描述的是正常的行为fancyhdr
,因此,由于您没有得到该结果,则意味着您的很长一段时间内存在其他问题不那么简单的工作示例是罪魁祸首。
问题在于您在设置页眉后更改了页面几何形状。只需将该部分移至任何geometry
更改之后即可解决此问题。
输出
代码
\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage{gensymb}
\usepackage{tabularx,array,booktabs} % for stretching tables to page width
\newcolumntype{Y}{>{\centering\arraybackslash}X} % for centering tables in tabularx
\newcolumntype{N}{@{}m{0pt}@{}} % for vertical space in tabularx
\newcommand{\heading}[1]{\bfseries\begin{tabular}{@{}c@{}} #1 \end{tabular}} % for a header in tables
\def\tabularxcolumn#1{m{#1}} % for vertically centering text in tables
\usepackage{float}
\usepackage[landscape]{geometry}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{pstricks-add} % for geogebra
\usepackage{amsmath,amssymb}
\usepackage{fancyhdr}
\usepackage{tcolorbox}% for framed rounded boxes
\tcbset{colframe=black,colback=white,colupper=black,
fonttitle=\bfseries,nobeforeafter,center title,size=small}
\tcbuselibrary{breakable}
\usepackage{framed}% for framed standard boxes
\linespread{1.2}
\newenvironment{Figure}
{\par\medskip\noindent\minipage{\linewidth}}
{\endminipage\par\medskip}
\newenvironment{cframed}
{
\begin{framed}\begin{center}
}
{
\end{center}\end{framed}
}
% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in}
}
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
}
% Turn off header and footer
%\pagestyle{empty}
% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%x
{\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
{-1explus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%
{\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{1ex plus .2ex}%
{\normalfont\small\bfseries}}
\makeatother
% Define BibTeX command
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
% Don't print section numbers
%\setcounter{secnumdepth}{0}
\setcounter{secnumdepth}{1}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}
\pagestyle{fancy}
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt}
\lfoot{Left footer}
\cfoot{Center footer}
\rfoot{\hfill Right footer}
% -----------------------------------------------------------------------
\begin{document}
\raggedright
\footnotesize
\begin{multicols}{3}
% multicol parameters
% These lengths are set only within the two main columns
\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]
\end{multicols}
\end{document}