
Estoy usandoalnumsecpara una numeración de secciones alfanumérica. Tengo un nuevo comando \myreference
para crear referencias con el hyperref
paquete. Esto funciona bien.
Quiero que todas mis notas a pie de página creadas por \myreference
terminen con un punto. Por eso necesito comprobar si la sección (por ejemplo: I.1.) ya termina con un punto. Intenté usarlo \IfEndWith{\detokenize{\ref{#1}}}{.}{(already has dot)}{.}
pero no funciona.
Este es mi ejemplo:
\documentclass[]{report}
\usepackage{hyperref}
\usepackage{xstring}
\usepackage{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection}
\alnumsecstyle{Ral}
\newcommand{\myreference}[1]{
\footnote{
See page \pageref{#1}, section \ref{#1}
\IfEndWith{\detokenize{\ref{#1}}}{.}{(already has dot)}{.}
}
}
\begin{document}
\section{Section}\label{a}
First section\myreference{a}
\subsection{jkhahjkas}
My subsection.
\subsubsection{three}\label{b}
Third section\myreference{b}
\end{document}
\endinput
Respuesta1
\ref
no es expandible, por lo que \IfEndWith
realmente no puede funcionar con \ref
, pero \getrefnumber
desde refcount
el paquete es expandible. El paquete se carga de hyperref
todos modos.
\documentclass[]{report}
\usepackage{xstring}
\usepackage{hyperref}
\usepackage{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection}
\alnumsecstyle{Ral}
\newcommand{\myreference}[1]{
\footnote{
See page \pageref{#1}, section \ref{#1}
\IfEndWith{\getrefnumber{#1}}{.}{(already has dot)}{.}
}
}
\begin{document}
\section{Section}\label{a}
First section\myreference{a}
\subsection{jkhahjkas}
My subsection.
\subsubsection{three}\label{b}
Third section\myreference{b}
\end{document}
Respuesta2
Puedes usar \@addpunct
from amsthm
which no agregará su argumento si el factor de espacio actual es mayor que 1000. Sin embargo, esto requiere cambiar un poco el factor de espacio después de los números romanos.
\documentclass[]{report}
\usepackage{amsthm} % for \@addpunct
\usepackage{hyperref}
\usepackage{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection}
\alnumsecstyle{Ral}
\protected\def\Romanperiod{\spacefactor1001 .}
\surroundRoman{}{\Romanperiod}
\makeatletter
\newcommand{\myreference}[1]{% <-- don't forget
\footnote{% <-- don't forget
See page~\pageref{#1}, section~\ref{#1}\@addpunct{.}% <-- don't forget
}% <-- don't forget
}
\makeatother
\begin{document}
\section{Section}\label{a}
First section\myreference{a}
\subsection{jkhahjkas}
My subsection.
\subsubsection{three}\label{b}
Third section\myreference{b}
\end{document}
No olvide enmascarar el final de línea en las definiciones de macro.