I (not me, an answer to Using section sign (ยง) for cross-references to sections) have redefined the command \ref to be able to get the symbol \S:
\makeatletter
\renewcommand*{\p@section}{\SectionSymbol}% Add section symbol to section reference
\makeatother
The problem comes when I'm in an italic environment (like a theorem). Then, the numbers given by \ref{whatever} are italic. How can I solve it (avoiding use cleveref package if it is possible)?
MWE
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}
\newtheorem{remark}{Remark}
\makeatletter
\renewcommand*{\p@section}{\S}% Add section symbol to section reference
\renewcommand*{\p@subsection}{\P}
\makeatother
\begin{document}
\section{A}
\lipsum[1]
\subsection{A.1}
\label{a}
\lipsum[2]
\subsection{A.2}
\begin{remark}
\ref{a} \lipsum[2]
\end{remark}
\end{document}
