Ok here is my minimized .tex file:
\documentclass[12pt,twoside]{article}
\usepackage{lipsum}
\usepackage{fancyhdr} % pagina
\fancyfoot{} % styl paginy
\fancyhead[RO,LE]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancypagestyle{plain}{
\fancyhf{} % empty header and footer
\renewcommand{\headrulewidth}{0pt} % ho header line
\renewcommand{\footrulewidth}{0pt} % not footer line
}
\usepackage[a4paper, % wymiary strony
left=3.5cm,
right=2cm,
top=2cm,
bottom=2cm,
includefoot=false,
includehead=false]{geometry}
\usepackage{emptypage} % brak numeracji na pustych stronach
\title{xxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxx}
\author{xxxxxxxxxxxxxxxxxxxx} % autor
%Preambuła_koniec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dokument_start
\begin{document}
\maketitle % strona tytulowa
\cleardoublepage
\vspace*{\fill}
\begin{flushright}
tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst
\end{flushright}
\vspace*{\fill}
\cleardoublepage
\tableofcontents % spis tresci
\cleardoublepage
\newgeometry{left=3.5cm, % redefiniowana geometria
right=2cm,
top=2cm,
bottom=2cm,
includefoot=false,
includehead}
\pagestyle{fancy}
\section{section}
\thispagestyle{plain}
\subsection{subsection}
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\cleardoublepage
\section{section2}
\thispagestyle{plain}
\subsection{subsection2}
\lipsum
\lipsum
\lipsum
\lipsum
\lipsum
\end{document}
this:
\fancyfoot{} % styl paginy
\fancyhead[RO,LE]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancypagestyle{plain}{
\fancyhf{} % empty header and footer
\renewcommand{\headrulewidth}{0pt} % ho header line
\renewcommand{\footrulewidth}{0pt} % not footer line
}
should compile header with section title on right and page number on left in even pages, and subsection on left and page number on right in odd pages. BUT it only shows page number in pdf file after compilation:
(even) 8_____________________
(odd) _____________________9
shoudl be this:
(even) 8_________sectiontitle
(odd) subsectiontitle______9
Thanks for help!
Here is my full preamble and sample .tex with @cfr correction, but now instead of section and subsection titles there is "table of content" in my header
\documentclass[12pt,twoside]{article} % rozmiar czcionki, druk dwustronny, klasa mwart
\usepackage{palatino} % czcionka Palatino
\usepackage[T1]{fontenc} % wymagane do dzialania czcionki Palatino
\linespread{1.05} % interlinia, 1.05 ze wzgledu na czcionke Palatino
\usepackage[utf8]{inputenc} % kodowanie dokumentu
\usepackage[english,polish]{babel} % kroj czcionki w jezyku polskim i angielskim
\usepackage[MeX]{polski} % slownik lamania wyrazow w jezyku polskim
\usepackage[a4paper, % wymiary strony
left=3.5cm,
right=2cm,
top=2cm,
bottom=2cm,
headheight=15pt,
includefoot=false,
includehead=false]{geometry}
\usepackage{csquotes} % cudzyslowy
\usepackage{graphicx} % pakiet graficzny, wymagany do wstawiania rysunkow
\usepackage{float} % rysunki w zadanym miejscu
\usepackage{enumitem} % spis tresci i listy
\usepackage{indentfirst} % aktywne pierwsze wciecie w akapicie
\usepackage{etoolbox} % pakiet umozliwiajacy edycje domyslnych komend
\usepackage{amsmath} % pakiet matematyczny
\usepackage{bm} % dla pogrubionych i pochylonych czcionek w srodowisku matematycznym
\usepackage{ragged2e}
\usepackage[font=footnotesize, % otoczenie podpisow tabel i rysunkow
justification=RaggedRight,
singlelinecheck=false,
format=hang,
labelfont=bf,
labelsep=period,
compatibility=false]{caption}
\usepackage{titling} % tytulowanie
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tocloft} % spis tresci wraz z komenda dla kropek w rozdzialach
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}
\usepackage[compact]{titlesec} % zmiana czcionki i odstepow w tytulach rozdzialow
\titleformat{\section}
{\normalfont\fontsize{16pt}{16pt}\bfseries}
{\makebox[\mylen][l]{\thesection.}}
{0pt}
{}
\titleformat{\subsection}
{\normalfont\fontsize{14pt}{14pt}\bfseries}
{\makebox[\mylen][l]{\thesubsection.}}
{0pt}
{}
\titleformat{\subsubsection}
{\normalfont\fontsize{12pt}{12pt}\bfseries}
{\makebox[\mylen][l]{\thesubsubsection.}}
{0pt}
{}
\titlespacing*{\section}{0pt}{*0}{14pt} % zmiana odstepow po tytulach rozdzialow
\titlespacing*{\subsection}{0pt}{14pt}{12pt}
\titlespacing*{\subsubsection}{0pt}{12pt}{0pt}
\DeclareQuoteAlias{croatian}{polish} % deklaracja cudzyslowow
\setlist[enumerate,1]{label=\arabic*),leftmargin=1.25cm} % odsuniecie wypunktowania
\setlist[itemize,1]{label=-,labelsep=0.4cm,leftmargin=1.25cm}
\setlist[itemize,2]{label=-,labelsep=0.4cm,leftmargin=0.6cm}
\setlength\parindent{1.25cm} % wciecie 1.25cm
\newlength\mylen
\setlength\mylen{\parindent}
\addto\captionspolish{\renewcommand{\figurename}{Rys.}} % zmiana domyslnego podpisu dla rysunku
\renewcommand{\thetable}{\arabic{section}.\arabic{table}} % zmiana domyslnej numeracji dla rysunkow itp.
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
\usepackage{fancyhdr} % pagina
\fancyfoot{} % styl paginy
\fancyhead[RO,LE]{\thepage}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancypagestyle{plain}{
\fancyhf{} % empty header and footer
\renewcommand{\headrulewidth}{0pt} % ho header line
\renewcommand{\footrulewidth}{0pt} % not footer line
}
%%%%%%%%%%%%%%%%%%%%%%%% % strona tytulowa (en.wikibooks.org/wiki/LaTeX/Title_Creation)
\renewcommand*{\maketitle}{
\begin{titlepage}
\centering
\vspace{2cm}
{\Large \textbf{xxxxxxxxxxx}\par}
\vspace{2cm}
{\LARGE \textbf{xxxxxxxxxxxx}\par}
\vspace{2cm}
{\Large \textbf{\theauthor}\par}
{\Large xxxxxxxxxxxxxxxx\par}
\vspace{1cm}
\rule{0.8\textwidth}{1.5pt}
{\LARGE \thetitle\par}
\rule{0.8\textwidth}{1.5pt}
\vfill
{\Large xxxxxxxxxxx\\xxxxxxxxxxxxxxxx\par}
\vspace{1cm}
{\Large xxxxxxxxxxxxxxx}
\end{titlepage}
}
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% % komendy do bibliografii
% brak kropek na końcu refa
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{lipsum}
\hyphenation{Stren-gth} % dzielenie wyrazow
\newcommand{\varA}[1]{{\operatorname{\mathit{#1}}}} % zmienna matematyczna
\usepackage{emptypage} % brak numeracji na pustych stronach
\title{xxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxx\\xxxxxxxxxxxxxxxxxxxxxxxxxx}
\author{xxxxxxxxxxxxxxxx} % autor
\begin{document}
\begingroup
\pagestyle{plain}
\maketitle % strona tytulowa
\cleardoublepage
\vspace*{\fill}
\begin{flushright}
tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst\\ tekst tekst
\end{flushright}
\vspace*{\fill}
\cleardoublepage
\tableofcontents % spis tresci
\cleardoublepage
\endgroup
\newgeometry{left=3.5cm, % redefiniowana geometria
right=2cm,
top=2cm,
bottom=2cm,
headheight=15pt,
includefoot=false,
includehead}
\pagestyle{fancy}
\section{section1}
\thispagestyle{plain}
\label{sec:wstep}
\subsection{subsection1}
\lipsum
\lipsum
\lipsum
\lipsum
\subsection{subsection2}
\lipsum
\lipsum
\lipsum
\lipsum
\subsection{subsection3}
\lipsum
\lipsum
\lipsum
\cleardoublepage
\section{section3}
\thispagestyle{plain}
\label{sec:geometria}
\subsection{subsection4}
\lipsum
\lipsum
\lipsum
\lipsum
\subsubsection{subsection5}
\lipsum
\lipsum
\lipsum
\lipsum
\clearpage
\end{document}