TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

LaTeX noob here. Basically I get the following message in sharetex:

 main.tex: File ended while scanning use of \\definition.
<inserted text> \par <*> main.tex I suspect you have forgotten a `}', causing me to read past where you wanted me to stop. I'll try to recover; but if the error is serious, you'd better type `E' or `X' now and fix your file. ! Emergency stop. <*> main.tex *** (job aborted, no legal \end found).

I think I have pinpointed the region where I get the error message, as when I put \end{document} before this region it compiles but when I put it after it doesn't. Please could you see if there's any mistake?

Suppose $f : X\longrightarrow Y$ is a function, and $A\subseteqX$, $B\subseteqY$.
\\*\item[(i)] We define the image set of f, denoted im(f), by im(f)=$\{f(x) \vert x\inX\}$.
\item[(ii)] We define the image set of A under f, denoted f(A), by f(A)=$\{f(x) \vert x\in A\}$.
\item[(iii)] We define the inverse image set of B under f, denoted $f^{-1}(B)$, by $f^{-1}(B)=\{x\inX \vert f(x)\in B\}$.
share|improve this question
Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – someonr Dec 13 '13 at 1:22
up vote 0 down vote accepted

The immediate cause of the error you're getting would appear to be the \\* snippet; I can't tell what it's for. LaTeX will also choke on \inX, \subseteqX, and \subseteqY; there needs to a be a gap between the control sequence and the subsequent material. The use of \item statements while not in a list environment (such as itemize or enumerate) is also going to throw an error.

I would strongly recommend using \mid rather than \vert when expressing thoughts such as "conditional on", "given that", and "subject to". The macro \mid adds some horizontal spacing around the vertical bar, whereas \vert does not. Knuth, by the way, also recommends inserting \, (a "thin space") after the opening left curly brace and before the closing right curly brace in the conditioning statement.

Since you posted a code snippet rather than an entire MWE (minimum working example), I had to make a guess as to how the definition environment is defined.

enter image description here

\theoremstyle{definition} % adjust this setup to your needs
\newcommand{\image}{\mathit{im}} % better to define a macro to define the appearance of "image"
Suppose $f : X\longrightarrow Y$ is a function, and $A\subseteq X$, $B\subseteq Y$.
\item[(i)] We define the image set of $f$, denoted $\image(f)$, by $\image(f)=\{\,f(x) \mid  x\in X\,\}$.
\item[(ii)] We define the image set of $A$ under $f$, denoted $f(A)$, by $f(A)=\{\,f(x) \mid  x\in A\,\}$.
\item[(iii)] We define the inverse image set of $B$ under $f$, denoted $f^{-1}(B)$, by $f^{-1}(B)=\{\,x\in X \mid  f(x)\in B\,\}$.
share|improve this answer
I'd rather make my own macro instead of the \mid, could be as simple as \let\given\mid then the code makes much more sense $\{ x \in A \given x^2 \in A \}$ – daleif Dec 13 '13 at 8:55
@daleif - Point taken. The main issue I meant to raise was that \vert is definitely not correct in this context. – Mico Dec 13 '13 at 9:17
of course, I tend to define macros for things like \{ ... \given ... \} via \DeclarePairedDelimiter such that \given get its height via the scaling choice in the macro. I think this is a better approach because users tend to get confused when they discover that \mid` does not scale. – daleif Dec 13 '13 at 9:37
Thanks a lot, my problem was sorted and you also answered another question of mines before I even asked it. Thanks again, friend. – Eduardo Dec 13 '13 at 17:02

Your code snippet says nothing about used packages, hence definition is commented. This is only a suggestion, but the general type of errors is: omitting space between macro name and next X or Y. Please observe also that f and $f$ are different objects. Probably also im should be as \sin, i.e. upright, with some spacing.



Suppose $f : X\longrightarrow Y$ is a function, and 
$A\subseteq X$, $B\subseteq Y$. 
\item[(i)] We define the image set of $ f$, denoted $im(f)$, by $ im(f)={f(x) \vert x\in X}$. 
\item[(ii)] We define the image set of $A$ under$ f$, denoted $f(A)$, by$ f(A)={f(x) \vert x\in A}$. 
\item[(iii)] We define the inverse image set of  $B$ under $f$, denoted $f^{-1}(B)$, by $f^{-1}(B)={x\in X \vert f(x)\in B}$. 



enter image description here

share|improve this answer
Please do not promote users to use \item[(i)] to number their lists. – daleif Dec 13 '13 at 8:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.