章节编号后保留句号,但引用章节时不保留句号

章节编号后保留句号,但引用章节时不保留句号

我知道之前已经讨论过这个问题,而且我也在使用其他帖子中的一些建议,但我很难将这些建议应用到自己的代码中。这是我的.cls文件中的一部分:

% section heading formats
\def\section{\@startsection {section}{1}{\z@}%
    {-3.5ex \@plus -1ex \@minus -.2ex}%
    {2.3ex \@plus.2ex}%
    {\normalfont\large\bfseries}}
\def\subsection{\@startsection{subsection}{2}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\itshape}}
% redefine section, figure etc. format
\def\thesection       {\arabic{section}} **%Note: removed period**
\def\thesubsection    {\thesection\arabic{subsection}.}
\def\thesubsubsection {\thesubsection\arabic{subsection}.}
\def\figurename{Fig.}
\def\tablename{Table}

      **%Note: I added this so that periods still remain on section titles but not when being referred inline**
\usepackage{tocloft}
\usepackage{titlesec}
\titleformat{\section}
  {\normalfont\bfseries}{\thesection.}{0.5em}{}
\renewcommand\cftsecaftersnum{.} 
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}

第二条注释下的代码段是我从之前的一个线程中获得的,它可以很好地删除参考文献中的句号,但不能删除章节标题,问题是我失去了较小尺寸的字幕。

我感觉我真的很接近了,但我一直在努力保留这两个功能 - 如果我可以提供更多代码或信息,请告诉我。

编辑:整个.cls文件

%%% Partnership for Advanced Computing in Europe 
%%%   www.prace-ri.eu
%%%
%%% LaTeX document class for a PRACE-RI whitepaper.
%%%
%%% (c) CSC - IT Center for Science Ltd.
%%%   author: Martti Louhivuori ([email protected])
%%%
%%% Requires: LaTeX2e
%%%           geometry, graphicx, ifthen, booktabs
%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{prace}[2013/03/26 PRACE-RI Whitepaper class]

\DeclareOption{onecolumn}{\OptionNotUsed}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax

\LoadClass[a4paper]{article}

% A4: 210x297mm - 20mm margins
\RequirePackage{geometry}
\geometry{text={170mm,257mm}, centering}
\RequirePackage{graphicx}
\RequirePackage{ifthen}
\RequirePackage{booktabs}

% page numbering
\pagenumbering{arabic}
%\pagestyle{empty}
% default font
\renewcommand{\normalsize}{\fontsize{10}{11}\selectfont}

% default values
\def\projectname{}
\def\authortel{+0-000-000-0000}
\def\authorfax{+0-000-000-0000}
\def\authoremail{[email protected]}

% internal counters
\newcounter{praceauth}
\setcounter{praceauth}{0}
\renewcommand\thepraceauth{\alph{praceauth}}
\newcounter{praceaffi}
\setcounter{praceaffi}{0}
\renewcommand\thepraceaffi{\alph{praceaffi}}
\newcounter{pracetmp}
\setcounter{pracetmp}{0}
\renewcommand\thepracetmp{\alph{pracetmp}}

% project ID & author contact details
\newcommand\project[1]{\renewcommand\projectname{#1}}
\newcommand{\email}[1]{\renewcommand\authoremail{#1}}
\newcommand{\tel}[1]{\renewcommand\authortel{#1}}
\newcommand{\fax}[1]{\renewcommand\authorfax{#1}}

% tag corresponding author
\newif\if@iscorresponding
\@iscorrespondingfalse
\newif\if@hascorresponding
\@hascorrespondingfalse
\newcommand\corresponding[0]{\@iscorrespondingtrue\@hascorrespondingtrue}
% corresponding author footnote
\long\def\authorfootnote{%
    \def\thefootnote{\fnsymbol{footnote}}%
    \csname c@\@mpfn\endcsname 1\relax%
    \xdef\@thefnmark{\thempfn}%
    \@footnotetext}
% corresponding author contact detail footnote
\def\authorcontact{%
    \authorfootnote{Corresponding author.\\%
    \indent\hspace{1ex} 
    tel. \authortel{}\hspace{1ex}
    fax. \authorfax{}\hspace{1ex} 
    e-mail. \authoremail{}}
    }

% tmp flag
\newif\if@praceflag
\@praceflagfalse

% convert integers to letters
\def\csvitoalist{}
\newcommand\csvitoa[1]{
    \def\csvitoalist{}
    \@for\name:=#1\do{
        \setcounter{pracetmp}{\name}
        \if@praceflag
            \edef\csvitoalist{\csvitoalist,\thepracetmp}
        \else
            \edef\csvitoalist{\thepracetmp}
            \@praceflagtrue
        \fi}
    \@praceflagfalse
    \csvitoalist
    }

% store author definitions for later use
\def\authorlist{}
\def\tmpname{}
\renewcommand\author[2][a]{%
    %
    \def\alfalist{}
    \@for\name:=#1\do{
        \setcounter{pracetmp}{\name}
        \if@praceflag
            \edef\alfalist{\alfalist,\thepracetmp}
        \else
            \edef\alfalist{\thepracetmp}
            \@praceflagtrue
        \fi}
    \@praceflagfalse
    %
%   \def\alfalist{\csvitoa{#1}}
    %
    \def\tmpname{#2}
    \if@iscorresponding
        \edef\tmpname{\tmpname{}${}^{\alfalist{},*}$}
    \else
        \edef\tmpname{\tmpname{}${}^{\alfalist}$}
    \fi
    \ifnum \c@praceauth >\z@
        \edef\authorlist{\authorlist{}, \tmpname{}}
    \else
        \edef\authorlist{\tmpname{}}
    \fi
    \@iscorrespondingfalse
    \addtocounter{praceauth}{1}
}
% store affiliation definitions for later use
\def\affiliationlist{}
\newcommand\affiliation[2][a]{%
    \addtocounter{praceaffi}{1}
    \def\tmpname{{${}^{\thepraceaffi}$#2}}
    \ifnum \c@praceaffi >\@ne
        \edef\affiliationlist{\affiliationlist{},\tmpname{}}
    \else
        \edef\affiliationlist{\tmpname{}}
    \fi%
}
% output affiliation list
\newcommand\affiliationblock[0]{%
    \@for\name:=\affiliationlist\do{\name\\}}

% title block
\renewcommand{\maketitle}{%
  \newpage
    \noindent\begin{minipage}{3cm}
    %\includegraphics[width=3cm]{prace-logo}
    \end{minipage}
    \begin{minipage}{11cm}
    \centering%
    %Available on-line at www.prace-ri.eu\\\vspace{1em}
    %{\large\bfseries Partnership for Advanced Computing in Europe}
    \end{minipage}
    \begin{minipage}{3cm}
    \end{minipage}\\
  \null
  \vskip 2em%
  \begin{center}%
  \let \footnote \thanks
    {\LARGE \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \authorlist
      \end{tabular}\par}%
    \vskip 1em%
        \affiliationblock
        \if@hascorresponding
            \authorcontact
        \else
            \@latex@warning{Corresponding author is undefined}
        \fi
  \end{center}%
  \par
  \vskip 1.5em%
}

% section heading formats
\def\section{\@startsection {section}{1}{\z@}%
    {-3.5ex \@plus -1ex \@minus -.2ex}%
    {2.3ex \@plus.2ex}%
    {\normalfont\large\bfseries}}
\def\subsection{\@startsection{subsection}{2}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\itshape}}
% redefine section, figure etc. format
\def\thesection       {\arabic{section}} %Josh: removed period
\def\thesubsection    {\thesection\arabic{subsection}.}
\def\thesubsubsection {\thesubsection\arabic{subsection}.}
\def\figurename{Fig.}
\def\tablename{Table}

      %Josh's Note: I added this so that periods still remain on section titles but not when being referred inline
\usepackage{tocloft}
\usepackage{titlesec}
\titleformat{\section}
  {\normalfont\bfseries}{\thesection.}{0.5em}{}
\renewcommand\cftsecaftersnum{.} 
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}


% add horisontal lines before and after the abstract
\renewenvironment{abstract}%
    {\noindent\rule{\textwidth}{0.1pt}
    \small
    \noindent{\bfseries \abstractname}
    \quotation}%
    {\vspace{0em}{\small \projectname}\\ %TOOK OUT Project ID after \small
    \noindent\rule{\textwidth}{0.1pt}}
% no indentation for quotations
\renewenvironment{quotation}%
    {\list{}{%
        \listparindent 0.0em
        \itemindent    \listparindent
        \rightmargin   \leftmargin
        \parsep        \z@ \@plus\p@}%
    \item\relax}
    {\endlist}

% add space either after table caption or before figure caption
\newif\if@withintable
\@withintablefalse
\newif\if@withinfigure
\@withinfigurefalse
\renewenvironment{figure}
    {\@withinfiguretrue\@float{figure}}
    {\end@float\@withinfigurefalse}
\renewenvironment{figure*}
    {\@withinfiguretrue\@dblfloat{figure}}
    {\end@dblfloat\@withinfigurefalse}
\renewenvironment{table}
    {\@withintabletrue\@float{table}}
    {\end@float\@withintablefalse}
\renewenvironment{table*}
    {\@withintabletrue\@dblfloat{table}}
    {\end@dblfloat\@withintablefalse}
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{10\p@}
\long\def\@makecaption#1#2{%
    \if@withinfigure
        \vskip\abovecaptionskip
    \fi
    {\small #1. #2\par}
    \if@withintable
        \vskip\belowcaptionskip
    \fi}

% ref.number in References
\def\@biblabel#1{\indent#1.}

编辑的代码保持字体大小一致,从参考文献中删除小数点但保留章节标题中的小数点,而且还删除小节标题中章节编号后的小数点(即 2.3. 变成 23.):

\def\thesection       {\arabic{section}} %Josh: removed period
\def\thesubsection    {\thesection\arabic{subsection}}
\def\thesubsubsection {\thesubsection\arabic{subsection}}
\def\figurename{Fig.}
\def\tablename{Table}
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}

\usepackage{tocloft}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{.}

答案1

.您可以按照以下方法在标题中的部分编号末尾添加:

\makeatletter
\def\thesection       {\arabic{section}}
\def\thesubsection    {\thesection\arabic{subsection}}
\def\thesubsubsection {\thesubsection\arabic{subsubsection}}
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother

\usepackage{tocloft}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{.}

所有句点都从计数器表示中删除,并在tional o er ting 宏 \the<secunit>中更新。这样,您仍然可以使用-而不必担心句点会跟着您。添加seccntformat\@seccntformat\label\reftocloft确保将 a.放置在 ToC 中的每个单元之后:

在此处输入图片描述

\documentclass{article}

\makeatletter
\def\thesection       {\arabic{section}}
\def\thesubsection    {\thesection\arabic{subsection}}
\def\thesubsubsection {\thesubsection\arabic{subsubsection}}
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother

\usepackage{tocloft}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{.}

\usepackage{lipsum}\sloppy% Just for this example

\begin{document}

\tableofcontents

See \ref{sec:first}, \ref{subsec:first} and \ref{subsubsec:first}.

\section{First section}\lipsum[1-10]\label{sec:first}
\subsection{First subsection}\lipsum[11-20]
\subsubsection{First subsubsection}\lipsum[21-30]
\subsubsection{Second subsubsection}\lipsum[31-40]
\subsubsection{Third subsubsection}\lipsum[41-50]
\subsubsection{Last subsubsection}\lipsum[1-10]

\subsection{Second subsection}\lipsum[11-20]\label{subsec:first}
\subsubsection{First subsubsection}\lipsum[21-30]
\subsubsection{Second subsubsection}\lipsum[31-40]
\subsubsection{Third subsubsection}\lipsum[41-50]
\subsubsection{Last subsubsection}\lipsum[1-10]

\subsection{Third subsection}\lipsum[11-20]
\subsubsection{First subsubsection}\lipsum[21-30]\label{subsubsec:first}
\subsubsection{Second subsubsection}\lipsum[31-40]
\subsubsection{Third subsubsection}\lipsum[41-50]
\subsubsection{Last subsubsection}\lipsum[1-10]

\subsection{Last subsection}\lipsum[11-20]
\subsubsection{First subsubsection}\lipsum[21-30]
\subsubsection{Second subsubsection}\lipsum[31-40]
\subsubsection{Third subsubsection}\lipsum[41-50]
\subsubsection{Last subsubsection}\lipsum[1-10]

\end{document}

如果您希望仅将.特定部分单元作为放置条件,则可以定义特定于单元的格式化宏。例如,.仅具有\subsection(非也\section\subsubsection

\makeatletter
\def\thesection       {\arabic{section}}
\def\thesubsection    {\thesection\arabic{subsection}}
\def\thesubsubsection {\thesubsection\arabic{subsubsection}}
\def\sectioncntformat{\thesection\quad}
\def\subsectioncntformat{\thesubsection.\quad}
\def\subsubsectioncntformat{\thesubsubsection\quad}
\renewcommand{\@seccntformat}[1]{\csname #1cntformat\endcsname}
\makeatother

\usepackage{tocloft}
\renewcommand{\cftsecaftersnum}{}
\renewcommand{\cftsubsecaftersnum}{.}
\renewcommand{\cftsubsubsecaftersnum}{}

在此处输入图片描述

相关内容