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

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

4 Answers 4

7

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}

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

enter image description here

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

4
  • 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.
    – egreg
    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
3

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}

titlesec results

2

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}

output

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

1

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.).

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.