1

I am new in latex and I need to express the following symbols:

&, &&, ^, | , || , <, <=, >, >= , == , != , %

When I write them in that way, nothing happens on the document. Please help.

best regards,

5 Answers5

5

The symbols can be set in verbatim mode, e.g.:

\documentclass{article}

\begin{document}
\begin{tabular}{ll}
  \verb|&|  & bitwise and\\
  \verb|&&| & logical and\\
  \verb|^|  & bitwise xor\\
  \verb+|+  & bitwise or\\
  \verb+||+ & logical or\\
  \verb|<|  & less than\\
  \verb|<=| & less than or equal to\\
  \verb|>|  & greater than\\
  \verb|>=| & greater than or equal to\\
  \verb|==| & equal to\\
  \verb|!=| & not equal to\\
  \verb|%|  & modulo\\
  \verb|~|  & bitwise not\\
\end{tabular}
\end{document}

Result

Program code can also be set via package listings.

Heiko Oberdiek
  • 271,626
1

You should put this in an equation environment, e.g.:

\begin{equation} 
 a <= b | c
\end{equation}

In this case your equation gets a number. To avoid this, do the following:

\begin{equation*} 
 a <= b | c
\end{equation*}

But if you want to write for example a simple % in your text, you can do it like this:

\%
Mackie
  • 140
1

Helping myself with the guide I linked in my comment above, here is a list of symbols of yours that you can render, inside or outside the math delimiters, not needing AMS-LaTeX packages or any other. The following code

\documentclass{article}

\begin{document}

a \& b \% c \textasciicircum{} d

\[
e \vert f | g < h \le i \ge j > k \ne l = m
\]

Also: $\|n\|$.

The following unescaped percent produces a comment % indeed this text does not show

\end{document}

produces:

screenshot of output

Check in the manual how to use more specific or sophisticated symbols provided by several dedicated packages.

MattAllegro
  • 1,546
1

The symbols like +, -, ||, <, > would work without the dollar symbols.

The more critical symbols and some good practices of using it are explained and suggested as follows:

  1. For using ampersand (&) symbol, use backslash (\) before the symbol. The correct way of including the ampersand symbol in the document is as follows: \&.

  2. Any mathematical/greek symbols should be enclosed within $ $. For this, add \usepackage{amsmath}.
    For example: $+$, $-$ etc.
    Note: it's a good practice to enclose any used alphabets and mathematical symbols within dollar symbols, like: $a$ and $+$.

  3. For using the symbols percentage (%) and underscore (_), you need to add backslash (\) just before the symbol. The same is illustrated as follows.
    Suppose you want to write 99% and latex_symb. The correct way of writing the aforementioned words is as follows: 77\%, latex\_symb. (1)
    This will produce the output with no errors.
    Note: moreover, the use of dollar symbols in statement (1) is a good practice. This practice is optional. But using this, it will be efficient for differentiating the normal text and used mathematical words. The same is explained as follows, like this: $77\%$, $latex\_symb$.

Additionally, If you simply want the character to be printed just as any other letter, include a \ in front of the character. For example, \$ will produce $ in your output.

Hope this helps. Thank You.

M S
  • 1,552
  • 2
    you should click on tick to accept the best answer and upvote for others which helped you @user3097712. –  Aug 25 '15 at 05:57
1

You may try http://detexify.kirelabs.org/classify.html - just draw the symbol you are looking for and the applet there will give you the required packages (if necessary) as well as the code for the symbol...

Newbie
  • 231