|
回复 2# kuing
谢谢,原来这么多if类型,经过2楼提示,在网上找到一个ifdefined
不过还有些地方不太明白,猜测这个ifdefined应该是判断chapter是否定义过,如果定义过就把中间的执行了,但我下面的代码并不能运行。如果把\ifdefined\chapter改成\ifdefined\chaptername,这样就能成功运行了,也确实是我需要的效果:在article里就不管chapter了,在book里才使用定义的样式。那这个\chapter到底在哪定义过呢?为什么article里也找到它了?- \documentclass[10pt]{article}
- \usepackage[small,center,pagestyles]{titlesec}
- \ifdefined\chapter
- \titleformat{\chapter}[hang]{\Large\bfseries}{\chaptername}{1em}{}
- \renewcommand{\chaptername}{}
- \fi
- \begin{document}
- \tableofcontents
- \chapter{测试章}
- \section{测试节}
- 测试文本
- \end{document}
复制代码 |
|