为什么这个底部边距没有改变?

为什么这个底部边距没有改变?

我正在使用 mnras.cls 文件作为 latex 模板,并尝试加宽标题页的底部边距区域。当我尝试使用tex.stackexchange.com/questions/668911,我无法得到我想要的结果。虽然标题页是正确的,但第二页的底部边距仍然很宽。由于这种方法不起作用,我尝试了另一种方法。这一次,标题页的底部边距没有改变。我搞不清楚哪一步不起作用。为什么这不像我想象的那样有效

我的 MWE 如下,所有需要的文件都以压缩文件形式提供此链接

% Basic setup. Most papers should leave these options alone.
\documentclass[fleqn,usenatbib]{mnras}
\usepackage{newtxtext,newtxmath}
\usepackage[T1]{fontenc}

%%%%% AUTHORS - PLACE YOUR OWN PACKAGES HERE %%%%%
\usepackage{graphicx}   % Including figure files
\usepackage{amsmath}    % Advanced maths commands
\let\Bbbk\relax
\usepackage{amssymb}    % Extra maths symbols
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{afterpage}
\usepackage{calc}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
%%%%% AUTHORS - PLACE YOUR OWN COMMANDS HERE %%%%%

% Please keep new commands to a minimum, and use \newcommand not \def to avoid
% overwriting existing commands. Example:
%\newcommand{\pcm}{\,cm$^{-2}$} % per cm-squared
\newcommand{\atfirstpage}[1]{
  \ifnum#1=1% shrink the bottom area
    \addtolength{\textheight}{-10mm}
    \addtolength{\footskip}{10mm}
  \else
    \ifnum#1=0% restore the bottom area to previous values
      \addtolength{\textheight}{10mm}
      \addtolength{\footskip}{-10mm} 
    \fi
  \fi
}     

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%% TITLE PAGE %%%%%%%%%%%%%%%%%%%

% Title of the paper, and the short title which is used in the headers.
% Keep the title short and informative.
\title[Short title, max. 45 characters]{MNRAS \LaTeXe\ template -- title goes here}

% The list of authors, and the short list which is used in the headers.
% If you need two or more lines of authors, add an extra line using \newauthor
\author[K. T. Smith et al.]{
Keith T. Smith,$^{1}$\thanks{E-mail: [email protected] (KTS)}
and
A. N. Other,$^{2}$
\\
% List of institutions
$^{1}$Royal Astronomical Society, Burlington House, Piccadilly, London W1J 0BQ, UK\\
$^{2}$Department, Institution, Street Address, City Postal Code, Country\\
}

% These dates will be filled out by the publisher
\date{Accepted XXX. Received YYY; in original form ZZZ}

% Enter the current year, for the copyright statements etc.
\pubyear{2015}

\atfirstpage{1} % shrink the text area

% Don't change these lines
\begin{document}
\label{firstpage}
\pagerange{\pageref{firstpage}--\pageref{lastpage}}
\maketitle

\afterpage\aftergroup\atfirstpage{0} % restore the text area

\begin{textblock}{185}(15,248.2)
    \noindent\rule{0.92\textwidth}{0.3mm}
    \noindent\fbox{%
        \parbox{0.945\textwidth}{%
            \vspace*{1mm}%
            {\footnotesize
                \textbf{Corresponding author:\,}Author name\\
                \textbf{Submitted:\,}00.00.0000
                \,\textbf{\,Accepted:\,}00.00.0000
                \,\textbf{\,Published Online:\,}00.00.0000}
        }
    }
\end{textblock}

% Abstract of the paper
\begin{abstract}
This is a simple template for authors to write new MNRAS papers.
The abstract should briefly describe the aims, methods, and main results of the paper.
It should be a single paragraph not more than 250 words (200 words for Letters).
No references should appear in the abstract.
\end{abstract}

% Select between one and six entries from the list of approved keywords.
% Don't make up new ones.
\begin{keywords}
keyword1 -- keyword2 -- keyword3
\end{keywords}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% BODY OF PAPER %%%%%%%%%%%%%%%%%%
\section{Introduction}

This is a simple template for authors to write new MNRAS papers.
See \texttt{mnras\_sample.tex} for a more complex example, and \texttt{mnras\_guide.tex}
for a full user guide.

\section{Methods, Observations, Simulations etc.}

Normally the next section describes the techniques the authors used.
It is frequently split into subsections, such as Section~\ref{sec:maths} below.

\subsection{Maths}
\label{sec:maths} % used for referring to this section from elsewhere

Simple mathematics can be inserted into the flow of the text e.g. $2\times3=6$
or $v=220$\,km\,s$^{-1}$, but more complicated expressions should be entered
as a numbered equation:

\begin{equation}
    x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}.
    \label{eq:quadratic}
\end{equation}

Refer back to them as e.g. equation~(\ref{eq:quadratic}).

\subsection{Figures and tables}

Figures and tables should be placed at logical positions in the text. Don't
worry about the exact layout, which will be handled by the publishers.

Figures are referred to as e.g. Fig.~\ref{fig:example_figure}, and tables as
e.g. Table~\ref{tab:example_table}.

% Example figure
\begin{figure}
    % To include a figure from a file named example.*
    % Allowable file formats are eps or ps if compiling using latex
    % or pdf, png, jpg if compiling using pdflatex
    \includegraphics[width=\columnwidth]{example.png}
    \caption{This is an example figure. Captions appear below each figure.
    Give enough detail for the reader to understand what they're looking at,
    but leave detailed discussion to the main body of the text.}
    \label{fig:example_figure}
\end{figure}

% Example table
\begin{table}
    \centering
    \caption{This is an example table. Captions appear above each table.
    Remember to define the quantities, symbols and units used.}
    \label{tab:example_table}
    \begin{tabular}{lccr} % four columns, alignment for each
        \hline
        A & B & C & D\\
        \hline
        1 & 2 & 3 & 4\\
        2 & 4 & 6 & 8\\
        3 & 5 & 7 & 9\\
        \hline
    \end{tabular}
\end{table}


\section{Conclusions}

The last numbered section should briefly summarise what has been done, and describe
the final conclusions which the authors draw from their work.

\section*{Acknowledgements}

The Acknowledgements section is not numbered. Here you can thank helpful
colleagues, acknowledge funding agencies, telescopes and facilities used etc.
Try to keep it short.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Data Availability}
The inclusion of a Data Availability Statement is a requirement for articles published in MNRAS. Data Availability Statements provide a standardised format for readers to understand the availability of data underlying the research results described in the article. The statement may refer to original data generated in the course of the study or to third-party data analysed in the article. The statement should describe and provide means of access, where possible, by linking to the data or providing the required accession numbers for the relevant databases or DOIs.


%%%%%%%%%%%%%%%%%%%% REFERENCES %%%%%%%%%%%%%%%%%%

% The best way to enter references is to use BibTeX:

%\bibliographystyle{mnras}
%\bibliography{example} % if your bibtex file is called example.bib

% Alternatively you could enter them by hand, like this:
% This method is tedious and prone to error if you have lots of references
\begin{thebibliography}{99}
\bibitem[\protect\citeauthoryear{Author}{2012}]{Author2012} Author A.~N., 2013, Journal of Improbable Astronomy, 1, 1
\bibitem[\protect\citeauthoryear{Others}{2013}]{Others2013} Others S., 2012, Journal of Interesting Stuff, 17, 198
\end{thebibliography}

% Don't change these lines
\bsp    % typesetting comment
\label{lastpage}
\end{document}

我的 MWE 结果是这样的 我的 MWE 测试结果

答案1

由于一些原因,它无法正常工作。其中一些我在之前您链接的答案中已经介绍过了。

  1. 您不能说\afterpage\aftergroup\atfirstpage{0}。只有\aftergroup被传递给\afterpage(我认为如此,但可能错了)它什么都不做。 的参数\afterpage需要放在括号中。而且只将一个参数传递给 更简单\aftergroup。 绝对\aftergroup\atfirstpage{0}不是您想要的效果。只需执行两个命令即可完成。
  2. 正如我在之前的回答中所说,一列和两列之间的切换会造成麻烦\afterpage。即使您\afterpage在第一列调用,它也适用于第二列。如果要在第一列调用它,则需要调用它两次(嵌套)。

我建议使用钩子来简化代码。这样,您就可以在文档开头更改边距,然后在环境\afterpage之后触发代码keywords。这样做的唯一缺点是,如果没有keywords环境,边距将不会重置。

因此设置的代码将如下所示:

\newcommand{\atfirstpageyes}{%
  \addtolength{\textheight}{-10mm}%
  \addtolength{\footskip}{10mm}%
}     
\newcommand{\atfirstpagenoaux}{%
  \addtolength{\textheight}{10mm}%
  \addtolength{\footskip}{-10mm}%
}
\newcommand{\atfirstpageno}{\afterpage{\aftergroup\atfirstpagenoaux}}
% hook to shrink text area at start of document
\AtBeginDocument{\atfirstpageyes}
% hook to expand text area on page following end of keywords env
\AddToHook{env/keywords/after}{\afterpage{\aftergroup\atfirstpageno}}

完整 MWE

% Basic setup. Most papers should leave these options alone.
\documentclass[fleqn,usenatbib]{mnras}
\usepackage{lipsum}
\usepackage{newtxtext,newtxmath}
\usepackage[T1]{fontenc}

%%%%% AUTHORS - PLACE YOUR OWN PACKAGES HERE %%%%%
\usepackage{graphicx}   % Including figure files
\usepackage{amsmath}    % Advanced maths commands
\let\Bbbk\relax
\usepackage{amssymb}    % Extra maths symbols
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{afterpage}
\usepackage{calc}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
%%%%% AUTHORS - PLACE YOUR OWN COMMANDS HERE %%%%%

% Please keep new commands to a minimum, and use \newcommand not \def to avoid
% overwriting existing commands. Example:
%\newcommand{\pcm}{\,cm$^{-2}$} % per cm-squared
\newcommand{\atfirstpageyes}{%
  \addtolength{\textheight}{-10mm}%
  \addtolength{\footskip}{10mm}%
}     
\newcommand{\atfirstpagenoaux}{%
  \addtolength{\textheight}{10mm}%
  \addtolength{\footskip}{-10mm}%
}
\newcommand{\atfirstpageno}{\afterpage{\aftergroup\atfirstpagenoaux}}
% hook to shrink text area at start of document
\AtBeginDocument{\atfirstpageyes}
% hook to expand text area on page following end of keywords env
\AddToHook{env/keywords/after}{\afterpage{\aftergroup\atfirstpageno}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%% TITLE PAGE %%%%%%%%%%%%%%%%%%%

% Title of the paper, and the short title which is used in the headers.
% Keep the title short and informative.
\title[Short title, max. 45 characters]{MNRAS \LaTeXe\ template -- title goes here}

% The list of authors, and the short list which is used in the headers.
% If you need two or more lines of authors, add an extra line using \newauthor
\author[K. T. Smith et al.]{
Keith T. Smith,$^{1}$\thanks{E-mail: [email protected] (KTS)}
and
A. N. Other,$^{2}$
\\
% List of institutions
$^{1}$Royal Astronomical Society, Burlington House, Piccadilly, London W1J 0BQ, UK\\
$^{2}$Department, Institution, Street Address, City Postal Code, Country\\
}

% These dates will be filled out by the publisher
\date{Accepted XXX. Received YYY; in original form ZZZ}

% Enter the current year, for the copyright statements etc.
\pubyear{2015}

% Don't change these lines
\begin{document}
\label{firstpage}
\pagerange{\pageref{firstpage}--\pageref{lastpage}}
\maketitle

\begin{textblock}{185}(15,248.2)
    \noindent\rule{0.92\textwidth}{0.3mm}
    \noindent\fbox{%
        \parbox{0.945\textwidth}{%
            \vspace*{1mm}%
            {\footnotesize
                \textbf{Corresponding author:\,}Author name\\
                \textbf{Submitted:\,}00.00.0000
                \,\textbf{\,Accepted:\,}00.00.0000
                \,\textbf{\,Published Online:\,}00.00.0000}
        }
    }
\end{textblock}

% Abstract of the paper
\begin{abstract}
This is a simple template for authors to write new MNRAS papers.
The abstract should briefly describe the aims, methods, and main results of the paper.
It should be a single paragraph not more than 250 words (200 words for Letters).
No references should appear in the abstract.
\end{abstract}

% Select between one and six entries from the list of approved keywords.
% Don't make up new ones.
\begin{keywords}
keyword1 -- keyword2 -- keyword3
\end{keywords}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% BODY OF PAPER %%%%%%%%%%%%%%%%%%
\section{Introduction}

This is a simple template for authors to write new MNRAS papers.
See \texttt{mnras\_sample.tex} for a more complex example, and \texttt{mnras\_guide.tex}
for a full user guide.

\section{Methods, Observations, Simulations etc.}

Normally the next section describes the techniques the authors used.
It is frequently split into subsections, such as Section~\ref{sec:maths} below.

\subsection{Maths}
\label{sec:maths} % used for referring to this section from elsewhere

Simple mathematics can be inserted into the flow of the text e.g. $2\times3=6$
or $v=220$\,km\,s$^{-1}$, but more complicated expressions should be entered
as a numbered equation:

\begin{equation}
    x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}.
    \label{eq:quadratic}
\end{equation}

Refer back to them as e.g. equation~(\ref{eq:quadratic}).

\subsection{Figures and tables}

Figures and tables should be placed at logical positions in the text. Don't
worry about the exact layout, which will be handled by the publishers.

Figures are referred to as e.g. Fig.~\ref{fig:example_figure}, and tables as
e.g. Table~\ref{tab:example_table}.

% Example figure
\begin{figure}
    % To include a figure from a file named example.*
    % Allowable file formats are eps or ps if compiling using latex
    % or pdf, png, jpg if compiling using pdflatex
    \includegraphics[width=\columnwidth]{example-image-duck}
    \caption{This is an example figure. Captions appear below each figure.
    Give enough detail for the reader to understand what they're looking at,
    but leave detailed discussion to the main body of the text.}
    \label{fig:example_figure}
\end{figure}

% Example table
\begin{table}
    \centering
    \caption{This is an example table. Captions appear above each table.
    Remember to define the quantities, symbols and units used.}
    \label{tab:example_table}
    \begin{tabular}{lccr} % four columns, alignment for each
        \hline
        A & B & C & D\\
        \hline
        1 & 2 & 3 & 4\\
        2 & 4 & 6 & 8\\
        3 & 5 & 7 & 9\\
        \hline
    \end{tabular}
\end{table}

\section{Conclusions}

The last numbered section should briefly summarise what has been done, and describe
the final conclusions which the authors draw from their work.

\section*{Acknowledgements}

The Acknowledgements section is not numbered. Here you can thank helpful
colleagues, acknowledge funding agencies, telescopes and facilities used etc.
Try to keep it short.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Data Availability}
The inclusion of a Data Availability Statement is a requirement for articles published in MNRAS. Data Availability Statements provide a standardised format for readers to understand the availability of data underlying the research results described in the article. The statement may refer to original data generated in the course of the study or to third-party data analysed in the article. The statement should describe and provide means of access, where possible, by linking to the data or providing the required accession numbers for the relevant databases or DOIs.

\section*{Lipsum}

\lipsum[1-5]

%%%%%%%%%%%%%%%%%%%% REFERENCES %%%%%%%%%%%%%%%%%%

% The best way to enter references is to use BibTeX:

%\bibliographystyle{mnras}
%\bibliography{example} % if your bibtex file is called example.bib

% Alternatively you could enter them by hand, like this:
% This method is tedious and prone to error if you have lots of references
\begin{thebibliography}{99}
\bibitem[\protect\citeauthoryear{Author}{2012}]{Author2012} Author A.~N., 2013, Journal of Improbable Astronomy, 1, 1
\bibitem[\protect\citeauthoryear{Others}{2013}]{Others2013} Others S., 2012, Journal of Interesting Stuff, 17, 198
\end{thebibliography}

% Don't change these lines
\bsp    % typesetting comment
\label{lastpage}
\end{document}

第 1 页底部

p1

第 2 页底部

p2

相关内容