LaTeX Error: \verb ended by end of line
This error appears when you have used a verbatim
command incorrectly. If you do this, you will generate the error below:
main.tex, line 5
See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.7 \unbrace{\verb+\error+} Try typing <return> to proceed. If that doesn't work, type X <return> to quit.
To resolve this error, it is best to use the verbatim
environment instead as shown below:
\begin{verbatim}
You should include your verbatim text in here.
\end{verbatim}
Common Causes
Including a line-break inside a \verb command:
One common cause for this error to occur is if you have used a \verb
command, but you have included a line-break, as shown below:
We can write different typefaces in \LaTeX as
\verb{
\textbf{Bold}
\textit{italics}
\textsf{sans serif}
}
This will generate an error, as line-breaks are not allowed inside the \verb
command. The correct way to write this is to use the verbatim
environment as shown below:
% In your preamble
\usepackage{verbatim}
% In the main body of your document
We can write different typefaces in \LaTeX as
\begin{verbatim}
\textbf{Bold}
\textit{italics}
\textsf{sans serif}
\end{verbatim}
Omitting an end character in a \verb command:
The verb command should be used as shown below:
\verb!\frac{1}{2}!
Note that delimiters here are not unique, and any character will do. The reason that we have used !
as our delimiter here is that there are no !
written in \frac{1}{2}
. If we had chosen to write \verb{\frac{1}{2}}
, we would generate the output below, which is not correct.
This can lead to problems, as an error will be generated if the start and end of the \verb
are not the same character. Because of this, all of the below commands will generate an error:
\verb \frac{1}{2}
{\verb \frac{1}{2}}
\verb!\frac{1}{2}
Once again, it is recommended to simply use the verbatim
environment to write this as shown below
\begin{verbatim}
\frac{1}{2}
\end{verbatim}
Using a \verb command inside another command:
Another way in which this error can appear is if a \verb
command is used inside another command as shown below
\section{\verb!\frac{1}{2}!}
This is not allowed in LaTeX, and is one of the few cases when the verbatim
environment won't help. To resolve this error, you should load the cprotect
package as shown below:
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips