【Latex】Latex Error:Two documentclass or documentstyle commands. documentclass{

今天尝试在latex中使用markdown语法时出现了如下错误:
在这里插入图片描述
Two \documentclass or \documentstyle commands. \documentclass{
在网上查找了好多地方,都说是因为用了两次\documentclass命令导致的,可是我能确定我只用了一次\documentclass命令,最后我终于找到了问题所在。因为我的tex文件名字也是markdown。
那么总结一下,出现这种情况可能的原因一般有两种:

  • 一种就是确实是用了两次documentclass命令
  • 另一种就是你的tex文件名字可能与包名或者环境名重复了

如果有人知道还有其他原因的话,欢迎在评论区指出

### LaTeX 文档操作指南 #### 插入目录 为了在 LaTeX 中插入目录,在文档的适当位置输入 `\tableofcontents` 命令即可。此命令通常放置于前言部分之后,正文之前[^1]。 ```tex \documentclass{IEEEtran} \begin{document} \title{Title of the Document} \author{Author Name} \maketitle \tableofcontents % Insert table of contents here % Rest of the document content follows... \end{document} ``` #### 实现分页功能 对于手动控制页面布局的情况,可以利用如下两个基本指令来实现分页效果: - 使用 `\newpage` 来结束当前页面并跳转到下一页; - 或者采用更加强制性的方法——`\clearpage`,它不仅会触发新页开始还会处理浮动对象(如图表)。 ```tex ... some text ... \newpage % Start a new page ... more text ... ``` #### 生成示例文本 要快速填充大量占位符文字以便查看排版效果,推荐使用 `zhlipsum` 宏包中的同名命令。安装该宏包后只需简单调用 `\zhlipsum{n}` 即可获得 n 段中文测试文章。 ```tex \usepackage{zhlipsum} % Add this line to preamble ... \section*{Test Section} \zhlipsum[2] % Generate two paragraphs of dummy Chinese text ``` #### 引入外部代码文件 当希望展示编程源码片段而不必直接嵌入 TeX 文件内时,借助 `listings` 包下的 `\lstinputlisting` 函数非常方便。指定目标语言参数以及待导入的具体路径/名称就可以完成这项工作了。 假设存在名为 `main.m` 的 MATLAB 脚本位于项目根目录,则可以通过下面的方式将其加载进来显示为带语法高亮的支持列表环境。 ```tex \usepackage{listings} % Include listings package in your preamble \lstset{ language=Matlab, % Set default listing style as Matlab syntax highlighting basicstyle=\ttfamily, numbers=left, numbersep=5pt, showstringspaces=false, breaklines=true } ... \subsection*{Code Example from External File} \lstinputlisting{main.m} % Import and display 'main.m' file with proper formatting ```
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值