我想为章节名称添加样式。我参考了以下链接: 如何在书籍文档类中创建特定章节样式
这是我的代码:
%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{titlesec}
% Can also use centering, or hcentering
\titleformat{\chapter}[display]
{\bfseries\Large}
{\filright\MakeUppercase{\chaptertitlename}\Huge\thechapter}
{1ex}
{\titlerule\vspace{1ex}\filleft}
[\vspace{1ex}\titlerule]
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
BackTrack is a distribution designed by Jason Dennis based on the Ubuntu Linux distribution aimed at digital forensics and penetration testing use. BackTrack provides users with easy access to a comprehensive and large collection of security-related tools ranging from port scanners to Security Audit. Support for Live CD and Live USB functionality allows users to boot BackTrack directly from portable media without requiring installation, though permanent installation to hard disk and network is also an option.\par
\end{document}
我得到以下输出:
explicit
使用该选项titlesec
并根据给出的解决方案对章节进行编号后,我得到了以下输出:
答案1
您正在加载titlesec
包两次 - 仅第一次实例实际计算,第二次被忽略。
当您使用explicit
选项titlesec
包裹,你有使用 指定标题#1
。
因此,您可以使用,例如,
\titleformat{\chapter}[display]
{\bfseries\Large}
{\filright\MakeUppercase{\chaptertitlename}\Huge\thechapter}
{1ex}
{\titlerule\vspace{1ex}\filleft #1}
[\vspace{1ex}\titlerule]
或者删除该选项并直接使用explicit
以下方式加载包titlesec
\usepackage{titlesec}
在这种情况下,您可以坚持使用原始代码。