在 Book 类中对章节进行样式设置时出错

在 Book 类中对章节进行样式设置时出错

我想从默认外观设计书籍类中的章节样式。我收到错误。这是代码:

%Template for Technical Document
\documentclass{book}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}  \usepackage{titlesec}
\renewcommand{\chaptername}{Article}
%% Can also use centering, or hcentering

\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0cm,trim right=2.5cm] {%
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (a) at (2.5cm,1ex) {%
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+2.15cm,-0.75ex);
}%
}

\newcommand\subtitlebar{%
\tikz[baseline,trim left=0cm,trim right=3.05cm] {%
    \node[
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3.05cm,0) {%
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}

\titleformat{\subsection}{\normalfont\sf}{\subtitlebar}{0.2cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{-2cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2.15cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}

\makeatletter
\newcommand{\chapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}\large\scshape#1}%
  \par\nobreak\vspace*{35pt}
  \@afterheading%
}
\makeatother

\titleformat{\chapter*}
{\normalfont\LARGE\bfseries}{1em}{}
\begin{document}
\chapter*{Install Backtrack on an Android Device}
\chapterauthor{K.DINESH KUMAR \par II Year B.Tech CSE}
\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
\section{Security Tools in Backtrack}
BackTrack includes many well known security tools including:
\begin{itemize}
    \item Metasploit for integration
    \item Wi-Fi drivers supporting monitor mode (rfmon mode) and packet injection
    \item Aircrack-ng
    \item Gerix Wifi Cracker
    \item Kismet
    \item Nmap
    \item Ophcrack
    \item Ettercap
    \item Wireshark (formerly known as Ethereal)
    \item BeEF (Browser Exploitation Framework)
    \item Hydra
    \item OWASP Mantra Security Framework, a collection of hacking tools, add-ons and scripts based on FirefoX.
    \item Cisco OCS Mass Scanner, a very reliable and fast scanner for Cisco routers with telnet and enabling of a default password.
\end{itemize}

\section{Installing Backtrack on Android Device}
\subsection{Tools Required}
\begin{enumerate}
\item Backtrack 5 ARM.\\
Download Backtrack 5 ARM from Backtrack official site. Backtrack with ARM architecture only on Backtrack 5 version. ARM architecture not available for Backtrack 5 R1, Backtrack 5 R2, and Backtrack 5 R3.
\item Rooted android device \\
Why rooted android device ? Because we need install some application that need Android to be root
\item Busybox, Superuser, Terminal Emulator, and AndroidVNC. \\
You can download search and all of them on Google Play. BusyBox is installer and uninstaller Android program, Superuser is superuser rights manager for Android, Terminal Emulator is Android's built-in Linux command line shell program, and AndroidVNC is a VNC viewer for Android.
\end{enumerate}
\subsection{Installation}
\begin{enumerate}
\item Extract BT5-GNOME-ARM.7z to folder, for example "BT5" folder and then put on device root directory.
\item Open Terminal Emulator on device then go to BT5 folder with command prompt. Here is  the command \verb+ cd sdcard/BT5 +
\item Then run this following command \verb+ su + and \verb+ sh bootbt + and you will see \verb+ root@localhost +
\item Now lets run Backtrack GUI with VNC viewer \verb+startvnc+
\item To connect wth VNC we must know the port where VNC listening. Run \verb+netstat -anpt+ and remember the port where VNC listening. In this case the port is 59016. Open AndroidVNC and fill the form like this: \\
Nickname : BT5\\
Password : toortoor\\
Address  : 127.0.0.1\\
Port     : 5901 \\
\item Connect it and you will see Backtrack 5 interface \par
\textit{Remember! Some of the Backtrack tools can't work properly and do it for your own risk. I hope you can Install Backtrack on Android device without any problems, tell me if you get problems.}
\end{enumerate}
\end{document} 

答案1

要更改 带星号版本的 的格式\chapter,您不能\chapter*直接在 的参数中使用\titleformat;您应该使用name=\chapter,numberless键。此外,\titleformat接收五个强制参数,而您只传递了四个。因此,您应该使用:

\titleformat{name=\chapter,numberless}
  {\normalfont\LARGE\bfseries}{}{1em}{#1}

(由于该选项正在使用中,因此使用了 #1 explicit)。但是,您似乎想要格式化\chapter,在本例中,

\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{}{0em}{#1}

代码:

%Template for Technical Document
\documentclass{book}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}  
\renewcommand{\chaptername}{Article}
% Can also use centering, or hcentering

\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0cm,trim right=2.5cm] {%
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (a) at (2.5cm,1ex) {%
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+2.15cm,-0.75ex);
}%
}

\newcommand\subtitlebar{%
\tikz[baseline,trim left=0cm,trim right=3.05cm] {%
    \node[
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3.05cm,0) {%
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}

\titleformat{\subsection}{\normalfont\sf}{\subtitlebar}{0.2cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{-2cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2.15cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}

\makeatletter
\newcommand{\chapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}\large\scshape#1}%
  \par\nobreak\vspace*{35pt}
  \@afterheading%
}
\makeatother

\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{}{0em}{#1}

\begin{document}
\chapter{Install Backtrack on an Android Device}
\chapterauthor{K.DINESH KUMAR \par II Year B.Tech CSE}
\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
\section{Security Tools in Backtrack}
BackTrack includes many well known security tools including:
\begin{itemize}
    \item Metasploit for integration
    \item Wi-Fi drivers supporting monitor mode (rfmon mode) and packet injection
    \item Aircrack-ng
    \item Gerix Wifi Cracker
    \item Kismet
    \item Nmap
    \item Ophcrack
    \item Ettercap
    \item Wireshark (formerly known as Ethereal)
    \item BeEF (Browser Exploitation Framework)
    \item Hydra
    \item OWASP Mantra Security Framework, a collection of hacking tools, add-ons and scripts based on FirefoX.
    \item Cisco OCS Mass Scanner, a very reliable and fast scanner for Cisco routers with telnet and enabling of a default password.
\end{itemize}

\section{Installing Backtrack on Android Device}
\subsection{Tools Required}
\begin{enumerate}
\item Backtrack 5 ARM.\\
Download Backtrack 5 ARM from Backtrack official site. Backtrack with ARM architecture only on Backtrack 5 version. ARM architecture not available for Backtrack 5 R1, Backtrack 5 R2, and Backtrack 5 R3.
\item Rooted android device \\
Why rooted android device ? Because we need install some application that need Android to be root
\item Busybox, Superuser, Terminal Emulator, and AndroidVNC. \\
You can download search and all of them on Google Play. BusyBox is installer and uninstaller Android program, Superuser is superuser rights manager for Android, Terminal Emulator is Android's built-in Linux command line shell program, and AndroidVNC is a VNC viewer for Android.
\end{enumerate}
\subsection{Installation}
\begin{enumerate}
\item Extract BT5-GNOME-ARM.7z to folder, for example "BT5" folder and then put on device root directory.
\item Open Terminal Emulator on device then go to BT5 folder with command prompt. Here is  the command \verb+ cd sdcard/BT5 +
\item Then run this following command \verb+ su + and \verb+ sh bootbt + and you will see \verb+ root@localhost +
\item Now lets run Backtrack GUI with VNC viewer \verb+startvnc+
\item To connect wth VNC we must know the port where VNC listening. Run \verb+netstat -anpt+ and remember the port where VNC listening. In this case the port is 59016. Open AndroidVNC and fill the form like this: \\
Nickname : BT5\\
Password : toortoor\\
Address  : 127.0.0.1\\
Port     : 5901 \\
\item Connect it and you will see Backtrack 5 interface \par
\textit{Remember! Some of the Backtrack tools can't work properly and do it for your own risk. I hope you can Install Backtrack on Android device without any problems, tell me if you get problems.}
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容