I have difficulty writing a compact command that allows me to insert a text between two lines. I read some links such as this and this, but each one treats the left and right line separately
\documentclass{article}
\usepackage{amsmath} %<<===
\usepackage[normalem]{ulem}
\usepackage{xcolor}
\newcommand\gsout{\bgroup\markoverwith{\textcolor{gray}{\rule[0.5ex]{2pt}{2.5pt}}}\ULon}
\newcommand*{\sxrule}[1][3em]{\textcolor{gray}{\rule[0.5ex]{#1}{2.5pt}}\;}
\begin{document}
\sxrule Osservazioni \gsout{\hfill}
\end{document}
Have any suggestions? thanks
\sxrule
.\;
as this is math-mode spacing so it needs to typed as$\;$
.