1

I'm basically brand new to Latex, so maybe this has a really simple answer I'm not seeing, but I'm having a problem where \frac isn't putting my first input over the numerator but instead to the side of the fraction.

the code looks like this

$\limi a_n=\limi \frac{1}{2} $

but it ends up looking like this

enter image description here


It's worth noting that \limi is a custom command I made with code

\newcommand{\limi}{$\lim\limits_{n\to\infty}$}

In addition, If I change \frac to be \tfrac or \dfrac it works just fine

Ex.

$\limi a_n=\limi \dfrac{1}{2} $

enter image description here


And last thing I've noticed is that if I delete my \limi command it fixes the problem, and \frac works like normal. So I'm guessing that it has something to do with my command code, but I can't figure out what's causing it. Help would be very much appreciated.

P.S.(I know that this equation doesn't make any sense, I changed the fraction to test the code, and so it would be easier to see)

1
  • 4
    never ignore error messages, remove the $ from your definition, you are already in math mode so \limi does not need to start math mode Oct 12, 2021 at 22:09

1 Answer 1

2

With the simple example

\documentclass{article}

\newcommand{\limi}{$\lim\limits_{n\to\infty}$}

\begin{document}

$\limi a_n=\limi \frac{1}{2} $

\end{document}

and hit return when errors are raised, I get the following on the console

This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2022/dev) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./limi.tex
LaTeX2e <2021-06-01> patch level 1
L3 programming layer <2021-08-27>
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/02/12 v1.4n Standard LaTeX document class
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file limi.aux.
! Missing $ inserted.
<inserted text>
                $
l.7 $\limi
           a_n=\limi \frac{1}{2} $
?
! Missing $ inserted.
<inserted text>
                $
l.7 $\limi a_
             n=\limi \frac{1}{2} $
?
! Missing $ inserted.
<inserted text>
                $
l.7 $\limi a_n=\limi
                     \frac{1}{2} $
?
! Missing $ inserted.
<inserted text>
                $
l.7 $\limi a_n=\limi \frac{1}{2}
                                 $
?
! Extra }, or forgotten $.
\frac  #1#2->{\begingroup #1\endgroup \over #2}

l.7 $\limi a_n=\limi \frac{1}{2}
                                 $
?
[1{/usr/local/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./limi.aux) )
(\end occurred inside a group at level 1)

### simple group (level 1) entered at line 7 ({)
### bottom level</usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts
/cm/cmmi7.pfb></usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/c
m/cmr10.pfb></usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/
cmr7.pfb></usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cms
y7.pfb>
Output written on limi.pdf (1 page, 36624 bytes).
Transcript written on limi.log.

When TeX issues an error message, it's essentially impossible to obtain correct output if one simply scrolls past errors.

Modify your code into

\newcommand{\limi}{\lim\limits_{n\to\infty}}

and you'll get no error, but dubiously useful output, because \limits will make the formula too big vertically to fit in a line. Example:

\documentclass{article}

\newcommand{\limi}{\lim\limits_{n\to\infty}}

\begin{document}

some text some text some text some text some text some text 
some text some text some text some text some text some text 
$\limi a_n=\limi \frac{1}{2} $
some text some text some text some text some text some text 
some text some text some text some text some text some text 

\end{document}

Output

enter image description here

Remove also \limits.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .