如果只有部分 *,如何使用 \numberwithin

如果只有部分 *,如何使用 \numberwithin
\documentclass[a8paper]{article} 

\usepackage[T1,T2A]{fontenc}
\usepackage[mathletters]{ucs}
\usepackage[utf8]{inputenc}
\usepackage[english,ukrainian]{babel}
\usepackage{ulem}
\usepackage{amsmath}
\usepackage{titlesec}
\usepackage{indentfirst}

\numberwithin{equation}{section}

\begin{document}
        \begin{center}
    \section*{\S 1. First}
       \end{center}
\begin{align}
            \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{1.1}
        \end{align}
\begin{center}
    \section*{\S 2. Second}
       \end{center}
\begin{align}
            \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{2.1}
        \end{align}
\end{document}

如何修复部分编号而非零

答案1

您加载titlesec:使用它!

\documentclass[a4paper]{article}

\usepackage[T1,T2A]{fontenc}
%\usepackage[utf8]{inputenc} % no longer needed
\usepackage[english,ukrainian]{babel}
\usepackage{amsmath}
\usepackage{titlesec}
\usepackage{indentfirst}

\numberwithin{equation}{section}

\titleformat{\section}[block]
 {\filcenter\Large\bfseries}
 {\S\thesection.}
 {0.5em}
 {}

\begin{document}

\section{First}

\begin{equation}
  \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{first}
\end{equation}

\section{Second}

\begin{equation}
  \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{second}
\end{equation}

\end{document}

在此处输入图片描述

不要加载ucs,它已经过时并且没有任何实际用处。

答案2

这是一个 XY 问题。您的部分\section编号,因此您一开始就不应该使用。要添加 §,您可以使用您已加载的包\section*的功能。titlesec

不确定您尝试对环境做什么center,但如果您希望将部分标题居中,您也可以这样做。

\documentclass[a8paper]{article} 

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ukrainian]{babel}
\usepackage{ulem}
\usepackage{amsmath}
\usepackage{titlesec}
\usepackage{indentfirst}

\numberwithin{equation}{section}

\titleformat{\section}[hang]%
    {\Large\bfseries\centering}% bold and Large and centered
    {\S\thesection.}% format of label
    {0.5em}% spacing between label and title
    {}% additional commands applied just to section title

\begin{document}
\section{First}

\begin{align}
    \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{1.1}
\end{align}

\section{Second}

\begin{align}
    \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  \label{2.1}
\end{align}
\end{document}

titlesec 结果

答案3

这是一个可能的解决方案:

\documentclass[a8paper]{article}

\usepackage[T1,T2A]{fontenc}
\usepackage[mathletters]{ucs}
\usepackage[utf8]{inputenc}
\usepackage[english,ukrainian]{babel}
\usepackage{ulem}
\usepackage{amsmath}
\usepackage{titlesec}
\usepackage{indentfirst}

\newcounter{paragraphCounter}
\numberwithin{equation}{paragraphCounter}

\newcommand{\createParagraph}[1]{%
    \stepcounter{paragraphCounter}%
    \section*{\S\ \theparagraphCounter.\hfill#1}%
}

\begin{document}
    \createParagraph{First}
    \begin{align}
        \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}
        \label{1.1}
    \end{align}

    \createParagraph{Two}
    \begin{align}
        \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}
        \label{2.1}
    \end{align}
\end{document}

输出

\hfill如果您不想要X.和等之间的空格First,请删除。Two

答案4

这是一个解决方案不是使用该titlesec包。相反,它采用了我多年前从《The LaTeX Companion(第二版)》一书中获得的方法。

在此处输入图片描述

\documentclass[a8paper]{article} % Are you sure 'a8paper' is meaningful?
\usepackage{geometry}
\usepackage[T1,T2A]{fontenc}
%%\usepackage[mathletters]{ucs}
\usepackage[utf8]{inputenc}
\usepackage[english,ukrainian]{babel}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{old-arrows} % optional

%%\usepackage{titlesec}
\usepackage{sectsty}
\sectionfont{\centering}
% Method proposed in "The LaTeX Companion", 2nd ed.:
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\space}    %  default
   {\csname #1@cntformat\endcsname}}  %  enable individual control
\newcommand\section@cntformat{\S\thesection.\space}  % section level
\makeatother

\counterwithin{equation}{section}

\begin{document}

\section{First}

\begin{equation}\label{1.1}
\overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  
\end{equation}
        

\section{Second}

\begin{equation}\label{2.1}
\overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}  
\end{equation}

\end{document}

相关内容