I think it is better post my code and then ask my question
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}
\usepackage[T1]{fontenc} % optional
\usepackage{thmtools}
\declaretheoremstyle[%
spaceabove=\topsep,
spacebelow=\topsep,
headfont=\small\normalfont,
bodyfont=\itshape\small,
headpunct={.---},
postheadspace=1em,
headformat=\NAME\space\NUMBER,
headindent= 0pt,
]{remark}
\declaretheorem[style=remark,numberwithin=subsection]{remark}
\renewcommand{\theremark}{\arabic{remark}}
\newcommand\rmk[1]{\textit{Remark} \textup{\ref{#1}}}
\makeatletter
\renewcommand*{\p@section}{\S} %Add section symbol to section reference
\renewcommand*{\p@subsection}{\P} %Add section symbol to section reference
\makeatother
\begin{document}
\section{A}
\lipsum[1]
\subsection{A.1}
\label{a}
\begin{remark}
\label{remark}
\lipsum[2]
\end{remark}
\lipsum[2]
\subsection{A.2}
\begin{remark}
\lipsum[2]
\end{remark}
\lipsum[3]
\section{B}
\lipsum[1]
\subsection{B.1}
As we can see in \ref{a}~\rmk{remark}...
\end{document}
As you can see in my code, remark enumeration (and other environment enumerations) are restarted at each subsection. I'm very happy with that, but the problem is that when I want to cross-reference a remark from another subsection, I must specify the subsection explicitly, by writing \ref{sec:stuff}
.
Is there a modification of my command \rmk
such that includes the subsection reference automatically? Maybe create a new command which tells you the current subsection of that environment?
zref
cleveref package
(I've even used it) but not aboutzref
. I'll looking at it on the internet. Thanks.