.tex 文档:

.tex 文档:

刚开始使用 LaTeX。我想先从生成一页的研究声明开始,然后这个简约的研究声明模板在 Overleaf 上。在示例中,它清楚地显示了页眉,包括分别在右上角和左上角的作者姓名和标题。

在此处输入图片描述

不幸的是,当我打开模板时,那些组件丢失了,而且我不知道如何纠正已经存在的内容来修复它。

在此处输入图片描述

这是主要的 .tex 文档,我尝试用我的详细信息替换YourName其中Statement Type

.tex 文档:

% 
% This format is intended to be used for frequently requested
% academic statements, like research and teaching statements.
%
% Uses Atkinson Hyperlegible font for better accessibility
%        (see https://brailleinstitute.org/freefont)
%
% Created by Acacia Ackles, 2021
%
% Free to share and redistribute with attribution (CC BY)
%

\documentclass[12pt]{ministate}

\name{YourName}
\statement{Statement Type}

\begin{document}

\runninghead

\thispagestyle{fancy}

Sample text about how cool you are at doing stuff.

Some more sample text. 

\textbf{A bold statement about you}, and how good your work is.

\bibliographystyle{plain}
\end{document}

它使用了 Arkinson Hyperlegible 字体并引用了 .cls 文件,我将把它附加到这里底部。

故障排除:

我查看了fancyhdr文档,但无法从中找出被滥用的地方。虽然我精通其他一些语言(Python、R、Bash 等),但我仍然对 LaTeX 中函数的定义方式感到困惑,我想知道问题是否出在这里。我确实尝试过完全跳过函数,直接在 .cls 文档的标题中指定我想要的文本,这些文本位于\@function_name标题函数中,但这也没有用。

我相信随着我学习更多 LaTeX,我会找到答案,但我想看看社区是否能给我指明正确的方向。无论如何,非常感谢您抽出时间!

.cls 文档:

\ProvidesClass{ministate}[2021/09/15 v1.0 Minimalist statement class]
\LoadClass[10pt,letterpaper]{article} % Font size and paper type

%--------------------------------------------------%
%                 packages                         %
%                                                  %
%--------------------------------------------------%
% Document Formatting
\usepackage[margin=1in]{geometry}
\usepackage{parskip}
\usepackage{fancyhdr}
\setlength{\headheight}{12pt}

% References and Citations
\usepackage{url}
\usepackage{hyperref}
\usepackage{natbib}

%--------------------------------------------------%
%                 Fonts                            %
%                                                  %
%--------------------------------------------------%

% !!!!!!! IMPORTANT !!!!!!!
% !! XELATEX COMPILATION REQUIRED !!
% Set compiler in Overleaf menu <-

\usepackage{fontspec} 
\usepackage{fontawesome}

% .ttf files required 
\setmainfont{AtkinsonHyperlegible}[ 
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic] 

%--------------------------------------------------%
%                 New Commands                     %
%                                                  %
%--------------------------------------------------%

% NAME AND TYPE OF STATEMENT
\def \name#1{\def\@name{#1}} % Defines the \name command to set name
\def \@name {} % Sets \@name to empty by default

\def \statement#1{\def\@statement{#1}} % Defines the \statement command to set type of statement
\def \@statement {} % Sets \@statement to empty by default


\def \runninghead{
  \begingroup
    \pagestyle{fancy}
    \fancyhf{}
    \rhead{\MakeUppercase{\bf \@name}}
    \lhead{\MakeUppercase{\bf \@statement}}
    \rfoot{\thepage}
  \endgroup
}

答案1

我将发布解决该问题的初始版本。该解决方案可能不是最佳的,我鼓励社区进一步改进它。

% The package requires XeLaTeX to compile because of the custom fonts.

% Credits to the original author: Acacia Ackles
% Original template: https://www.overleaf.com/latex/templates/minimalstatement/pzgpkvvrzyqj

% Modified by @GCerar
\ProvidesClass{ministate}[2023/03/29 v2.0 Minimalist statement class]
\LoadClass[11pt,a4paper]{article} % Font size and paper type % EDIT: Adapted fontsize and papersize

%--------------------------------------------------%
%                 packages                         %
%                                                  %
%--------------------------------------------------%
% Document Formatting
\usepackage[margin=0.8in]{geometry} % EDIT: A bit less margin
\usepackage{parskip}

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}

\fancyfoot{} % Override existing foot numbering
\fancyhf[HLE,HRO]{\bfseries\@author}
\fancyhf[HRE,HLO]{{\bfseries\@title}\quad(\@date)}
\fancyhf[FLE,FRO]{\thepage}

% References and Citations
\usepackage{url}
\usepackage{hyperref}
\usepackage{natbib}

% Fonts
\usepackage{fontspec} 
\usepackage{fontawesome}

% .ttf files required 
\setmainfont{AtkinsonHyperlegible}[ 
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic] 

该模板可以按如下方式使用:

% 
% This format is intended to be used for frequently requested
% academic statements, like research and teaching statements.
%
% Uses Atkinson Hyperlegible font for better accessibility
%        (see https://brailleinstitute.org/freefont)
%
% Created by Acacia Ackles, 2021
%
% Free to share and redistribute with attribution (CC BY)
%

\documentclass[12pt]{./ministate}

\author{Author's name}
\title{Statement Type}

\begin{document}

Sample text about how cool you are at doing stuff.

Some more sample text. 

\textbf{A bold statement about you}, and how good your work is.

\bibliographystyle{plain}
\end{document}

相关内容