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

4 Answers4

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.

egreg
  • 1,121,712
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

frabjous
  • 41,473
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.

Unknown
  • 822
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}

Mico
  • 506,678