# How to use \ numberwithin if there is only section *

\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}


How to fix that instead of zero there was a section number

• Do not link the section counter to the equations. Create your own counter. An example in this context you can find here. May 19 at 16:56
• Are you sure the a8paper option is meaningful?
– Mico
May 19 at 17:34
• \stepcounter{section} should work. May 20 at 4:06

You load titlesec: use it!

\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}

$$\overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2} \label{first}$$

\section{Second}

$$\overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2} \label{second}$$

\end{document}


Don't load ucs, it's obsolete and does nothing really useful.

• and how then to pick up in tableofcontents figures May 19 at 17:26
• @AndrijMatviiv The table of contents will be automatically produced if you issue \tableofcontents. May 19 at 17:27
• yes but it will have 1 paragraph character and again 1 May 19 at 17:29
• decided everything, thank you May 19 at 17:33

This is an XY problem. Your sections are numbered, so you should be using \section not \section* to begin with. To add the § you could use the capabilities of titlesec package, which you're already loading.

Not sure what you were attempting to do with the center environments, but if you want the section headings centered, you can do that as well.

\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}


Here is a possible solution:

\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}


Remove the \hfill if you do not want the space between X. and First, Two etc.

Here's a solution that does not employ the titlesec package. Instead, it employs a method I obtained years ago from the book The LaTeX Companion (2nd ed.).

\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}

$$\label{1.1} \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}$$

\section{Second}

$$\label{2.1} \overrightarrow{a} = a^1\overrightarrow{e_1}+a^2\overrightarrow{e_2}$$

\end{document}