You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX报错求助:Missing number等两类错误及命令触发问题

解决LaTeX中的“Missing number, treated as zero.”和“Illegal unit of measure (pt inserted).”错误

问题根源

你的代码里有几处关键问题直接触发了报错:

  • \renewcommand{\headrulewidth}{} 和 \renewcommand{\footrulewidth}{}:这两个命令需要接收长度值(如0pt)来设置页眉/页脚线宽度,空值会让LaTeX无法识别合法度量单位,导致报错。
  • hyperref包加载顺序错误:hyperref通常需要放在导言区最后加载(少数特殊包如cleveref除外),提前加载可能和其他包产生冲突,引发意外错误。
  • fontenc未指定编码:显式设置编码为T1,能避免字体渲染和命令解析的潜在问题。

修正后的完整代码

\documentclass[11pt, twocolumn, a4paper]{article}
\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % 显式指定T1编码
\usepackage[landscape, margin=1.5cm]{geometry} % 移除margin值里的空格,避免解析问题
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{fancyhdr}
\usepackage{capt-of}
\usepackage{booktabs}
\usepackage[colorlinks, linkcolor=black]{hyperref} % 移到最后加载

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{arabic}
\setlength{\columnsep}{1cm}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{\rightmark}
\fancyfoot{}
\fancyfoot[R]{\thepage} % 移除多余空格,避免页脚空白
\renewcommand{\headrulewidth}{0pt} % 设置为0pt隐藏页眉线
\renewcommand{\footrulewidth}{0pt} % 设置为0pt隐藏页脚线
\renewcommand{\thefigure}{\arabic{figure}}
\renewcommand{\thetable}{\arabic{table}}
\renewcommand{\familydefault}{\sfdefault}
\fontfamily{qag}\selectfont

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{titlepage}
% my personal template title
\end{titlepage}

\newpage
\section{测试章节}
\subsection{测试子章节}
\subsubsection{测试子子章节}
这是测试内容,验证\verb|\subsubsection|和\verb|\newpage|是否正常工作。

\paragraph{测试段落}
段落命令也能正常使用了。
\end{document}

额外说明

  • 移除margin=1.5 cm里的空格:虽LaTeX通常能容忍,但格式严谨可避免不必要的解析问题。
  • 添加测试内容:你可直接编译这段代码,验证\newpage、\subsubsection、\paragraph命令是否正常运行。

内容的提问来源于stack exchange,提问作者giuseppeantoniomotisi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 03:30:22