Fonts & Character SetsGetting certain characters when not in math mode [ ] for example

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
WasPentalive
Posts: 2
Joined: Mon Aug 04, 2025 6:24 am

Getting certain characters when not in math mode [ ] for example

Post by WasPentalive »

I am writing a manual for a programming language. I need to explain parts of this language that include the characters [ and ]. I am not working in math mode, just normal text. I have tried \], but that seems to work sometimes and not others.

! LaTeX Error: Bad math environment delimiter.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.613 Once an expression is closed by \]
the top of the stack is stored in
? X

P.S. I have been working with TeX / LaTeX for about 10 hours now... A little prior experience almost 30 years ago.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10358
Joined: Mon Mar 10, 2008 9:44 pm

Re: Getting certain characters when not in math mode [ ] for example

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

There was no answer yet, perhaps because it wasn't clear what the problem is, no error message and unclear what the output is with your document. This simply works without problem:

Code: Select all

\documentclass{article}
\begin{document}
Normal text: [parts]
\end{document}
Click "Run LaTeX here" to see that it works.

The error message you mentioned is for \], and yes, this is code for math equations. But you can write square brackets [ and ] simply in text mode. Even in math mode. Perhaps show some code that fails with it.

Stefan
LaTeX.org admin
WasPentalive
Posts: 2
Joined: Mon Aug 04, 2025 6:24 am

Re: Getting certain characters when not in math mode [ ] for example

Post by WasPentalive »

Thanks! I will try that right away.

I thought I had tried that and got some (stop and you can insert or run or exit here)

It did work... I thought I had tried just a bare [ and ] and had trouble... I guess I did not.

Thanks again.
Post Reply