解决使用latex报错Can be used only in preamble.
使用latex报错Can be used only in preamble.
文章共390字 · 阅读需要大约2分钟
一键AI生成摘要,助你高效阅读
问答
·
一、问题描述
使用latex想要绘制如下表格
但是出现了报错Can be used only in preamble.
二、解决
如果你在正文中引入了某个包或者类,而不是在序言(preamble
)中,那么就会发生这个错误。
- 在命令 \begin{document} 之前的内容,都被称为序言。在序言中,你定义文档的类型,文档的语言,以及很多基础的设定。例如,一般文档的序言大致是下面这个样子:
\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}
如果你在正文中引入了包(在 \begin{document}
之后),而不是在序言之中,那么就会报这个错误。
或者说你把包\usepackage{booktabs}
导入在其他地方任然会报这个错误。
这里需要把包\usepackage{booktabs}
导入在第一个\begin{document}
前面,就不会再报错了。
Ctrl+s编译就发现可以正常显示了:
更多推荐
已为社区贡献4条内容
所有评论(0)