GeneralProblems with \line in LaTeX picture

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
conker
Posts: 2
Joined: Mon Jun 02, 2008 2:13 pm

Problems with \line in LaTeX picture

Post by conker »

Although I just joined today, I have to say that the posts on this message board have always been tremendously helpful for me when I've had LaTeX problems in the past. I have a problem that I'm stumped on, and I can't find any resources that address my problem. It has to do with the \line object in the LaTeX picture environment.

My preamble looks like this:

Code: Select all

\documentclass[12pt,twoside,openany]{book}
\usepackage{fancyhdr}
\usepackage{asymptote}
\usepackage{latexsym}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{graphicx}
And the offending code looks like this:

Code: Select all

\begin{center}
  \begin{picture}(200,20) 
     \put(100,10){\line(1,0){50}} 
     \put(100,10){\vector(-1,0){50}} 
     \put(70,10){\circle*{3}} 
     \put(130,10){\circle*{3}}
     \put(70,1){\makebox(0,0){$A$}} 
     \put(130,1){\makebox(0,0){$B$}} 
     \put(150,18){\makebox(0,0){$\ell$}} 
  \end{picture}
\end{center}
Now, if I just replace the \line with a \vector, everything works fine. But right now, I am getting the following 8 error messages:

! Missing $ inserted.
<inserted text>
$
l.33 ...ture}(200,20) \put(100,10){\line(1,0){50}}
\put(100,10){\vector(-1,0...

! Extra }, or forgotten $.
\put ... \hb@xt@ \z@ {\kern #1\unitlength #3\hss }
\ignorespaces
l.33 ...ture}(200,20) \put(100,10){\line(1,0){50}}
\put(100,10){\vector(-1,0...

! Extra }, or forgotten $.
\endpicture ->\egroup
\hss \egroup \ht \@picbox \@picht \dp \@picbox \z@ \mb...
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

! Extra }, or forgotten $.
\endpicture ->\egroup \hss \egroup
\ht \@picbox \@picht \dp \@picbox \z@ \mb...
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

! Missing $ inserted.
<inserted text>
$
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

! Missing } inserted.
<inserted text>
}
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

! Missing } inserted.
<inserted text>
}
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

! Missing } inserted.
<inserted text>
}
l.33 ...0,18){\makebox(0,0){$\ell$}} \end{picture}
\end{center} \\

Any ideas what could be going wrong? Thanks!

Dennis

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Problems with \line in LaTeX picture

Post by Stefan Kottwitz »

Hi Dennis,

this code is working for me:

Code: Select all

\documentclass[12pt,twoside,openany]{book}
\usepackage{fancyhdr}
\usepackage{asymptote}
\usepackage{latexsym}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{graphicx}

\begin{document}
\begin{center}
  \begin{picture}(200,20)
     \put(100,10){\line(1,0){50}}
     \put(100,10){\vector(-1,0){50}}
     \put(70,10){\circle*{3}}
     \put(130,10){\circle*{3}}
     \put(70,1){\makebox(0,0){$A$}}
     \put(130,1){\makebox(0,0){$B$}}
     \put(150,18){\makebox(0,0){$\ell$}}
  \end{picture}
\end{center}
\end{document}
Try to compile it. Do you get the error again? If not, the problem should be somewhere else, then try to give a complete minimal working example.

Stefan
LaTeX.org admin
conker
Posts: 2
Joined: Mon Jun 02, 2008 2:13 pm

Re: Problems with \line in LaTeX picture

Post by conker »

Ah, I figured it out. Silly mistake---I did a \renewcommand on \line. :oops: Thanks Stefan!
Post Reply