设置两种类型的章节编号

设置两种类型的章节编号

我改变了章节编号的格式,所以每个章节名称都以实践 1:标题, 代替1. 标题问题是我想在文档的最后一部分(在附录中)将格式重置为原始格式,这样它就不会像实践 A:文本

有什么建议吗?

\documentclass[twoside]{article} 
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{fancyhdr}
\usepackage[toc,page]{appendix}

\makeatletter
% we use \prefix@<level> only if it is defined
\renewcommand{\@seccntformat}[1]{%
  \ifcsname prefix@#1\endcsname
    \csname prefix@#1\endcsname
 \else
    \csname the#1\endcsname\quad   
  \fi}
% define \prefix@section
\newcommand\prefix@section{Práctica \thesection: }
\makeatother

\renewcommand{\appendixpagename}{Anexos}
\renewcommand{\appendixtocname}{Anexos}

\begin{document}
\section{Medida del crecimiento y/o respiración celular}
%This section title is displayed as "Práctica 1: Medida del crecimiento y/o respiración celular"
\newpage
\begin{appendices}
\section{Códigos para Berkeley Madonna}
%This section title is displayed as "Práctica A:..." too.
\end{appendices}
\end{document}

答案1

快捷方式...再次\prefix@section在开头进行更改appendices以使用\prefix@@section定义为扩展为无的内容。

\g@addto@macro的用法添加\appendices\restoreprefixsection在 时自动执行的宏\begin{appendices}

\documentclass[twoside]{article} 
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{fancyhdr}
\usepackage[toc,page]{appendix}

\makeatletter
% we use \prefix@<level> only if it is defined
\renewcommand{\@seccntformat}[1]{%
  \ifcsname prefix@#1\endcsname
    \csname prefix@#1\endcsname
 \else
    \csname the#1\endcsname\quad   
  \fi}
% define \prefix@section

\newcommand{\prefix@@section}{Práctica }
\newcommand\prefix@section{\prefix@@section \thesection: }

\newcommand{\restoreprefixsection}{%
  \renewcommand{\prefix@@section}{}%
}

\g@addto@macro{\appendices}{\restoreprefixsection}

\makeatother

\renewcommand{\appendixpagename}{Anexos}
\renewcommand{\appendixtocname}{Anexos}

\begin{document}
\section{Medida del crecimiento y/o respiración celular}
%This section title is displayed as "Práctica 1: Medida del crecimiento y/o respiración celular"
\newpage
\begin{appendices}
\section{Códigos para Berkeley Madonna}
%This section title is displayed as "Práctica A:..." too.
\end{appendices}
\end{document}

相关内容