2

I wanted to use these two packages:

  • listings
  • matlab-prettifier

to write code and highlight it like in Matlab and insert it in my pdf. I added the packages like this:

\usep­a­ck­age{list­ings}
\usepackage[numbered,framed]{matlab-prettifier}

I am having trouble using them since when I try to compile I get this error:

! Undefined control sequence. <recently read> \usep l.46 \usep ­a­ck­age{list­ings} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx), type I and the correct spelling (e.g., I\hbox). Otherwise just continue, and I'll forget about whatever was undefined. ! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.46 \usep­ a­ck­age{list­ings} You're in trouble here. Try typing <return> to proceed.

The document has a begin{document} line and it works fine until I try to add the new package.

I followed this to install packages on the fly for miktex but it doesn't seem to help.

I don't undestand how to make it work, can someone please help me?

EDIT: The listings package seems to work in an example document such as this:

\documentclass{article}
\usepackage{listings}

\begin{document}
\lstset{language=Python}

 % Insert Pyhon examples here.

\end{document}
  • 2
    TeXmaker is an editor, you have to install packages through a LaTeX distribution. Have you installed mikTeX or TeXlive? (personally I would recommend TeXlive for new usersers) – Thorbjørn E. K. Christensen Nov 15 '17 at 10:17
  • I have mikTeX installed and it works perfectly with all other packages (babel, inputenc,fontenc...) – gccallie Nov 15 '17 at 10:19
  • Welcome to TeX SX! LaunchMiKTeX Package Manager (admin) , right-click listings and matlab-prettifierand select install. – Bernard Nov 15 '17 at 10:19
  • I think it's already installed, when I right-click the options are "uninstall" and "properties". – gccallie Nov 15 '17 at 10:21
  • 1
    Please show the error message you got (all the lines in the log file from ! to ? in a code section ({} button) so line endings are preserved) \usepackage is not undefined so you have presumably a wrong command somewhere that is not defined but you have not shown your input or the error message so it is hard to help – David Carlisle Nov 15 '17 at 10:32
0

There's something weird going on with the syntax higlighting of \usep­a­ck­age{list­ings} in your question. It almost looks like there are extra invisible characters in the command, between \usep and ackage. You might have accidentally copied them from somewhere.

The error message you posted in the comments also implies something of the sort.

As a posible solution, try deleting the line from your TeX file and retyping it by hand.

  • Thank you, it worked. I probably copied the usepackage from the library documentation. That's why I got the error. – gccallie Nov 15 '17 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.