不完整的 ifElse

不完整的 ifElse

Overleaf 给我一个错误,说 if-else 不完整。文档中没有任何 if-else。我不确定为什么会出现错误。

如果我注释掉第二个,\item编译器就可以渲染 pdf。所以我想知道:

  • 如何将多个条目添加为项目符号?
  • 什么确切地if-else错误是什么?正如我所说,文档中没有。

Document.tex

\documentclass{resume}

\begin{document}

\fontfamily{ppl}\selectfont

\noindent


\begin{center}

        \csection{Publications}{\small
    \begin{itemize}
         \item \frcontent{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}{Lorem, Ipsum, \textbf{Dolor Sit}, Consectetur Adipiscing, Elit, Sed Do Eiusmod, Tempor Incididunt, Ut Labore, Et Dolore, Magna Aliqua. }

         \item \frcontent{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}{\textbf{Dolor Sit, A.}, Ipsums, C., Harrell, D. F., \& \textbf{Lorem Ipsum}. }
         
    \end{itemize}
    } %Line 19
    
    
    
 


\end{center}
\end{document}


这是resume.cls文件:

\LoadClass[14pt]{extreport}

\usepackage{ifthen}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{geometry}
\usepackage{array}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{xltabular}
\usepackage{graphicx}
\usepackage{outlines}

\setlist[itemize]{leftmargin=*}
\linespread{1.15}
\geometry{a4paper,
    left={0.5in},
    top={0.4in}, 
    right={0.5in},
    bottom={0.4in}
}
\newcommand\clink[1]{{\usefont{T1}{lmtt}{m}{n} #1 }}
\pagenumbering{gobble}
\newenvironment{csection}[2]{
    \textbf{#1} 
    \vspace{0.15cm} 
    \hrule 
    {#2}
}{}
\newenvironment{frcontent}[4]{
    {
        \textbf{#1} \leavevmode\newline
        {\footnotesize  
            \ifthenelse{\equal{#2}{}}{}{{#2 \leavevmode\newline}}
            \ifthenelse{\equal{#3}{}}{}{{#3 \leavevmode\newline}}
            \ifthenelse{\equal{#4}{}}{}{{\textit{#4}}}
        }
    }
}{}


这是编译器的错误消息。

Incomplete \iffalse; all text was ignored after line 19.
inserted text> 
                \fi 
<*> ExtraResumeFields.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.
<*> ExtraResumeFields.tex
                         
*** (job aborted, no legal \end found)

 
Here is how much of TeX's memory you used:
 10163 strings out of 478542
 157938 string characters out of 5850413
 485753 words of memory out of 5000000
 27964 multiletter control sequences out of 15000+600000
 406149 words of font info for 34 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 75i,1n,80p,486b,272s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

答案1

事实上,您的文档中确实有 if-else 语句,只是不太明显,因为它们隐藏在 的定义中frcontent。我认为问题基本上在于您使用的是frcontent只有 2 个参数的宏,而它实际上被定义为具有 4 个强制参数的环境。正如 lukeflo 在评论中指出的那样, 也是如此csection:它被定义为具有 2 个参数的环境,因此应该这样使用。

下面编译没有错误。

\documentclass[14pt]{extreport}

\usepackage{ifthen}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{geometry}
\usepackage{array}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{xltabular}
\usepackage{graphicx}
\usepackage{outlines}

\setlist[itemize]{leftmargin=*}
\linespread{1.15}
\geometry{a4paper,
    left={0.5in},
    top={0.4in}, 
    right={0.5in},
    bottom={0.4in}
}
\newcommand\clink[1]{{\usefont{T1}{lmtt}{m}{n} #1 }}
\pagenumbering{gobble}
\newenvironment{csection}[2]{
    \textbf{#1} 
    \vspace{0.15cm} 
    \hrule 
    {#2}
}{}
\newenvironment{frcontent}[4]{
    {
        \textbf{#1} \leavevmode\newline
        {\footnotesize  
            \ifthenelse{\equal{#2}{}}{}{{#2 \leavevmode\newline}}
            \ifthenelse{\equal{#3}{}}{}{{#3 \leavevmode\newline}}
            \ifthenelse{\equal{#4}{}}{}{{\textit{#4}}}
        }
    }
}{}

\begin{document}
\begin{center}

    \begin{csection}{Publications}{}
    \small
    \begin{itemize}
         \item \begin{frcontent}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}{Lorem, Ipsum, \textbf{Dolor Sit}, Consectetur Adipiscing, Elit, Sed Do Eiusmod, Tempor Incididunt, Ut Labore, Et Dolore, Magna Aliqua. }{}{}
         \end{frcontent}

        \item \begin{frcontent}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}{\textbf{Dolor Sit, A.}, Ipsums, C., Harrell, D. F., \& \textbf{Lorem Ipsum}. }{}{}
        \end{frcontent}
         
    \end{itemize}
    \end{csection}

\end{center}
\end{document}

相关内容