关于这个问题我可以将我的翻译与原文保留在一起吗?我学习了如何做 if,但是当我像这样在本文档中使用它时:
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\newif\ifdebug
\debugfalse
\debugtrue
\begin{document}
Arquivo compilado \ifdebug22:00\else\currenttime\fi h do dia \ifdebugTODAY\else\today\if.
\end{document}
它会引发错误:
! Undefined control sequence.
l.81 ...else\currenttime\fi h do dia \ifdebugTODAY
\else\today\if.
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.
! Extra \else.
l.81 ...currenttime\fi h do dia \ifdebugTODAY\else
\today\if.
I'm ignoring this; it doesn't match any \if.
)
! Incomplete \if; all text was ignored after line 81.
<inserted text>
\fi
<*> ./test2.tex
The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.
! Emergency stop.
<*> ./test2.tex
*** (job aborted, no legal \end found)
但如果我改变 if 行并添加一些空格:
Arquivo \ifdebug 22:00 \else \currenttime \fi h do dia \ifdebug TODAY \else \today \if .
错误变成:
! Incomplete \iftrue; all text was ignored after line 81.
<inserted text>
\fi
<*> ./test2.tex
The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.
! Emergency stop.
<*> ./test2.tex
*** (job aborted, no legal \end found)
有关的:
答案1
有两处拼写错误:
Arquivo compilado \ifdebug22:00\else\currenttime\fi h do dia \ifdebugTODAY\else\today\if.
第一个错误是\ifdebugTODAY
,它指的是一个未知的条件,所以这里和\debugTODAY
之间的空格很重要。\ifdebug
TODAY
\ifdebug22:00
由于后面的数字清楚地界定了条件\ifdebug
的名称,因此空格不是必需的。debug
第二个错误是\if
末尾的 。它应该是\fi
。
\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}
\newif\ifdebug
\debugfalse
\debugtrue
\begin{document}
Arquivo compilado \ifdebug 22:00\else\currenttime\fi h do dia \ifdebug TODAY\else\today\fi.
\end{document}