windowstex live 2021xelatex
书上说的使用appendix 后面的章节会变成附录A...可是我这里只是变成了1.,难道是因为我在cls文件里重新设置了section格式吗?
\documentclass[a4paper,10pt]{my_paper}
\usepackage{ctex}
\usepackage[top=30.0mm,bottom=25.0mm,left=22.5mm,right=22.5mm,headsep=8mm]{geometry}%设置页边距
\usepackage{array} %主要是增加列样式选项
\usepackage[dvipsnames]{xcolor}%颜色宏包
\usepackage{graphicx}%图片宏包
\usepackage{amsmath}%公式宏包
\usepackage{float} %限制浮动体的位置
\usepackage{pdfpages}
\usepackage{appendix}
\usepackage{listings}
\usepackage{textcomp}
\usepackage{titletoc}
\usepackage[T1]{fontenc}
\numberwithin{equation}{section}
\usepackage{newtxtext, newtxmath} %使用Times New Roman 字体的方法
\setCJKmainfont[AutoFakeBold=2.17]{FandolSong-Regular.otf}
\usepackage{caption}
\usepackage[dvipsnames]{xcolor} % 更全的色系
\lstset{
language = Python,
backgroundcolor = \color{yellow!10}, % 背景色:淡黄
basicstyle = \small\ttfamily, % 基本样式 + 小号字体
rulesepcolor= \color{gray}, % 代码块边框颜色
breaklines = true, % 代码过长则换行
%numbers = left, % 行号在左侧显示
%numberstyle = \small, % 行号字体
keywordstyle = \color{blue}, % 关键字颜色
commentstyle =\color{green!100}, % 注释颜色
stringstyle = \color{red!100}, % 字符串颜色
frame = lrtb, % 用(带影子效果)方框框住代码块
showspaces = false, % 不显示空格
columns = fixed, % 字间距固定
}
\begin{document}
\newpage
\appendix
\section{附录}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{my_paper}[2021/08/17 My custom CV class]
\LoadClass[10pt]{article}
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\RequirePackage{hyperref}
\titleformat{\section}
{\bfseries\zihao{4}\heiti\centering} %定义字体heiti黑体
{\bfseries\arabic{section}.}{1em}
{}
[]
\titleformat{\subsection}
{\zihao{-4}\bfseries} %
{\bfseries\arabic{section}.\bfseries\arabic{subsection}}{1em}
{}
[]
\titleformat{\subsubsection}
{\zihao{-4}\bfseries} %
{\bfseries\arabic{section}.\bfseries\arabic{subsection}.\bfseries\arabic{subsubsection}}{1em}
{}
[]
对于中文的标题格式建议用 ctex
宏集提供的接口……
\documentclass{ctexart}
\ctexset{
appendix = {
name = {附录}
},
section = {
format = {\bfseries\zihao{4}\heiti\centering},
number = {\bfseries\arabic{section}.},
aftername = {\hspace{1em}}
},
subsection = {
format = {\bfseries\zihao{-4}},
number = {\bfseries\arabic{section}.\bfseries\arabic{subsection}},
aftername = {\hspace{1em}}
},
subsubsection = {
format = {\bfseries\zihao{-4}},
number = {\bfseries\arabic{section}.\bfseries\arabic{subsection}.\bfseries\arabic{subsubsection}},
aftername = {\hspace{1em}}
},
}
\begin{document}
\section{测试}
\subsection{测试}
\subsubsection{测试}
\appendix
\section{附录测试}
\end{document}