姆韦,
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\maketitle
\tableofcontents
\chapter{}
\end{document}
我想要
逐字逐句。总是得到Can be used only in preamble.
是否有基本解决方案?
答案1
您可以使用listings
包;这里有一个小例子:
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{maincs}{RGB}{177,0,39}
\definecolor{secondarycs}{RGB}{255,179,246}
\definecolor{tertiarycs}{RGB}{0,149,86}
\lstset{
language=[LaTeX]TeX,
basicstyle=\ttfamily\small,
columns=fullflexible,
breaklines=true,
texcsstyle=*\color{maincs},
texcs={documentclass,begin,end,chapter},
moretexcs=[2]{usepackage},
texcsstyle=*[2]{\color{secondarycs!80!black}},
moretexcs=[3]{maketitle,title,author,tableofcontents},
texcsstyle=*[3]{\color{tertiarycs}}
}
\begin{document}
\begin{lstlisting}
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\title{}
\author{}
\begin{document}
\maketitle
\tableofcontents
\chapter{}
\end{document}
\end{lstlisting}
\end{document}