Comment supprimer le point de section dans \ ref {}? [dupliquer]
Oct 15 2020
J'ai renouvelé ma section avec un point et je veux obtenir un nombre sans point lorsque j'utilise \ ref {}. Comment puis-je le faire?
\documentclass[11pt]{article}
\renewcommand\thesection{\normalsize{\arabic{section}.}}
\begin{document}
\section{Introduction} \label{s-1}
I want to print just a number of Section \ref{s-1} without dot.
\end{document}
Réponses
2 Mico Oct 15 2020 at 13:23
Voici une solution qui ne nécessite aucun package LaTeX externe.
\documentclass[11pt]{article}
%% Do _not_ do this:
%\renewcommand\thesection{\normalsize{\arabic{section}.}}
%% Instead, do this:
% Method proposed in "The LaTeX Companion", 2nd ed.
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\space}% default
{\csname #1@cntformat\endcsname}}% enable individual control
\newcommand\section@cntformat{\thesection.\space} % section-level
\makeatother
\begin{document}
\section{Introduction} \label{s-1}
I can cross-reference the number of Section \ref{s-1} without a trailing dot.
\end{document}
2 StevenB.Segletes Oct 15 2020 at 12:25
Plutôt que de changer le sens de \thesection, je le laisse tel quel, sans le point, et change la manière dont l'en-tête de section est sorti, en spécifiant un suffixe à ajouter \thesection, par exemple.
\documentclass[11pt]{article}
%\renewcommand\thesection{\normalsize{\arabic{section}.}}
\makeatletter
%% SECTIONING \hskip'S BEFORE SECTIONING TITLES
\def\sectionkern {1em}
\def\subsectionkern {1em}
\def\subsubsectionkern{1em}
\def\paragraphkern {1em}
%% SUFFIX ADDED TO \the SECTIONING MACROS
\def\sectionsuffix {.}
\def\subsectionsuffix {}
\def\subsubsectionsuffix{}
\def\paragraphsuffix {}
%% SECTIONING LABEL: \the[section]\[section]suffix\hskip\[section]kern
\renewcommand\@seccntformat[1]{\normalsize\csname the#1\endcsname%
\csname#1suffix\endcsname\hskip\csname#1kern\endcsname\relax}
\makeatother
\begin{document}
\section{Introduction} \label{s-1}
I want to print just a number of Section \ref{s-1} without dot.
\end{document}
2 Bernard Oct 15 2020 at 12:43
Vous avez une solution très simple avec titlesec, qui ajoute un point pour tous les niveaux de section et ne modifie pas \thesection& al.
\documentclass[11pt]{article}
\usepackage{titlesec}
\titlelabel{\thetitle. }
\begin{document}
\section{Introduction} \label{s-1}
I want to print just a number of Section \ref{s-1} without dot.
\end{document}