我正在使用‘article’ 包在 R 中,它允许根据预先指定的模板构建 R markdown 文档以供期刊提交。模板为 .tex 格式,如图所示,我使用的是 PLOS 模板。但是,我无法从上标中删除空格。
负责此操作的代码如下(我相信)
% Template for PLoS
% Version 3.4 January 2017
\documentclass[10pt,letterpaper]{article}
\usepackage[top=0.85in,left=2.75in,footskip=0.75in]{geometry}
% amsmath and amssymb packages, useful for mathematical formulas and symbols
\usepackage{amsmath,amssymb}
% Use adjustwidth environment to exceed column width (see example table in text)
\usepackage{changepage}
% Use Unicode characters when possible
\usepackage[utf8x]{inputenc}
% textcomp package and marvosym package for additional characters
\usepackage{textcomp,marvosym}
% cite package, to clean up citations in the main text. Do not remove.
% \usepackage{cite}
% Use nameref to cite supporting information files (see Supporting Information section for more info)
\usepackage{nameref,hyperref}
% line numbers
\usepackage[right]{lineno}
% ligatures disabled
\usepackage{microtype}
\DisableLigatures[f]{encoding = *, family = * }
% color can be used to apply background shading to table cells only
\usepackage[table]{xcolor}
% array package and thick rules for tables
\usepackage{array}
% create "+" rule type for thick vertical lines
\newcolumntype{+}{!{\vrule width 2pt}}
% create \thickcline for thick horizontal lines of variable length
\newlength\savedwidth
\newcommand\thickcline[1]{%
\noalign{\global\savedwidth\arrayrulewidth\global\arrayrulewidth 2pt}%
\cline{#1}%
\noalign{\vskip\arrayrulewidth}%
\noalign{\global\arrayrulewidth\savedwidth}%
}
% \thickhline command for thick horizontal lines that span the table
\newcommand\thickhline{\noalign{\global\savedwidth\arrayrulewidth\global\arrayrulewidth 2pt}%
\hline
\noalign{\global\arrayrulewidth\savedwidth}}
% Remove comment for double spacing
%\usepackage{setspace}
%\doublespacing
% Text layout
\raggedright
\setlength{\parindent}{0.5cm}
\textwidth 5.25in
\textheight 8.75in
% Bold the 'Figure #' in the caption and separate it from the title/caption with a period
% Captions will be left justified
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,justification=raggedright,singlelinecheck=off]{caption}
\renewcommand{\figurename}{Fig}
% Use the PLoS provided BiBTeX style
% \bibliographystyle{plos2015}
% Remove brackets from numbering in List of References
\makeatletter
\renewcommand{\@biblabel}[1]{\quad#1.}
\makeatother
% Leave date blank
\date{}
% Header and Footer with logo
\usepackage{lastpage,fancyhdr,graphicx}
\usepackage{epstopdf}
\pagestyle{myheadings}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{27.023pt}
\lhead{\includegraphics[width=2.0in]{PLOS-submission.eps}}
\rfoot{\thepage/\pageref{LastPage}}
\renewcommand{\footrule}{\hrule height 2pt \vspace{2mm}}
\fancyheadoffset[L]{2.25in}
\fancyfootoffset[L]{2.25in}
\lfoot{\sf PLOS}
%% Include all macros below
\newcommand{\lorem}{{\bf LOREM}}
\newcommand{\ipsum}{{\bf IPSUM}}
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$preamble$
\usepackage{forarray}
\usepackage{xstring}
\newcommand{\getIndex}[2]{%
\ForEach{,}{\IfEq{#1}{\thislevelitem}{\number\thislevelcount\ExitForEach}{}}{#2}
}
\setcounter{secnumdepth}{0}
\newcommand{\getAff}[1]{%
\getIndex{#1}{$for(address)$$address.code$$sep$,$endfor$}
}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\begin{document}
\vspace*{0.2in}
% Title must be 250 characters or less.
\begin{flushleft}
{\Large
\textbf\newline{$title$} % Please use "sentence case" for title and headings (capitalize only the first word in a title (or heading), the first word in a subtitle (or subheading), and any proper nouns).
}
\newline
\\
$for(author)$
$author.name$\textsuperscript{$for(author.affiliation)$\getAff{$author.affiliation$}$sep$, $endfor$}$if(author.corresponding)$\textsuperscript{*}$endif$$sep$,
$endfor$
\\
\bigskip
$for(address)$
\textbf{\getAff{$address.code$}}$address.address$\\
$endfor$
\bigskip
$for(author)$
$if(author.corresponding)$
* Corresponding author: $author.email$\\
$endif$
$endfor$
\end{flushleft}
% Please keep the abstract below 300 words
$if(abstract)$
\section*{Abstract}
$abstract$
$endif$
% Please keep the Author Summary between 150 and 200 words
% Use first person. PLOS ONE authors please skip this step.
% Author Summary not valid for PLOS ONE submissions.
$if(author_summary)$
\section*{Author summary}
$author_summary$
$endif$
\linenumbers
% Use "Eq" instead of "Equation" for equation citations.
$body$
\nolinenumbers
$if(biblio-files)$
\bibliography{$biblio-files$}
$endif$
\end{document}
先感谢您。
D.
答案1
由于没有 MWE 可以尝试,我只能猜测,您在\getAff
和的定义中引入了不需要的空格。 您可以通过在行尾\getIndex
添加来摆脱它:%
\newcommand{\getAff}[1]{% <-- HERE
\getIndex{#1}{$for(address)$$address.code$$sep$,$endfor$}% <-- HERE
}
\newcommand{\getIndex}[2]{% <-- HERE
\ForEach{,}{\IfEq{#1}{\thislevelitem}{\number\thislevelcount\ExitForEach}{}}{#2}% <-- HERE
}
要了解发生了什么,请看这里:行末百分号(%)有什么用?