未定義的控制序列錯誤,但不知道我的文件出了什麼問題

未定義的控制序列錯誤,但不知道我的文件出了什麼問題
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}

\title{\sc Homework 1}
\author{\sc by Me}
\date{\sc January 2017}

\begin{document}

\maketitle

\noindent 1) Show that $\sqrt{2} \in \mathbb{R} $
\vspace{1pc}

We will define two sequences, $A_k$ and $B_k$. 
Let $A_k = a_1.a_2a_3a_4\dots a_k$, and ${A_k}^2 > 2$ but decreasing the last digit, $a_k$, 
by 1 will result ${A_k}^2 < 2$.

\end{document}

(字型)<10.95> 在輸入行 12 上。未定義的控制序列。 l.12 \noindent 1) 顯示 $\sqrt{2} \in \mathbb {R} $

當我嘗試編譯此錯誤時,出現此錯誤。我仍然得到了我想要的 PDF 輸出,但它仍然困擾著我為什麼會彈出這個錯誤。我嘗試包含 amsmath、amstext 包,但它沒有修復錯誤。

答案1

上面顯示的格式的錯誤訊息不可讀,顯示 TeX 錯誤時應始終保留行結尾。

您的文檔中的錯誤是

! Undefined control sequence.
l.12 \noindent 1) Show that $\sqrt{2} \in \mathbb
                                                 {R} $
? h
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

? 

正如幫助文字清楚顯示的那樣,訊息中換行符的位置\mathbb是尚未定義的有問題的命令。

TeX 本身只能告訴你它沒有定義,而不是如何定義它,但谷歌搜尋該命令應該很快就會告訴你你需要這個包amsfonts

添加

\usepackage{amsfonts}

使文件沒有錯誤,但是 TeX 標記存在許多問題。

Latex2e 中不建議使用「兩個字母」字體命令(且預設未定義),通常最好使用 Latex 命令,\scshape但在這種情況下,通常您應該避免在文件中使用字體命令,尤其是在結構命令中,例如\title\author因為這些命令的重點在於它們只有純文字和數據,樣式取決於文檔類。出於類似的原因,您應該避免使用\vspace\noindent以及明確的編號,例如1)

在此輸入影像描述

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}

\makeatletter
% \@maketitle copied from article.cls, woth \ascshape added
\renewcommand\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \begin{center}%
\scshape
  \let \footnote \thanks
    {\LARGE \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
  \end{center}%
  \par
  \vskip 1.5em}
\makeatother

\title{Homework 1}
\author{by Me}
\date{January 2017}

\begin{document}

\maketitle

\begin{enumerate}
\item  Show that $\sqrt{2} \in \mathbb{R} $

\bigskip

We will define two sequences, $A_k$ and $B_k$. 
Let $A_k = a_1a_2a_3a_4\dots a_k$, and 
% You could use {A_k}^2 if you really need to stress the order
% bit it makes the 2 float off and normally the more compact
% form is used (and understood)
$A_k^2
 > 2$
but decreasing the last digit, $a_k$, 
by 
% math mode!
$1$ 
 will result
% as above
$A_k^2
 < 2$.
\end{enumerate}
\end{document}

相關內容