Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create a block around javascript code in latex.

I use minted package for format highlighting.

Here is my example code:

\documentclass[]{article}
\usepackage{minted}

%opening

\begin{document}

\begin{listing}[H]
\begin{minted}{js}
var http = require("http");
    http.createServer(function(request, response) {
        response.writeHead(200, {"Content-Type": "text/plain"});
        response.end();
    }).listen(8080);
\end{minted}
\caption{Example of a listing.}
\end{listing}

\end{document}

And I get the output as this

I would like to create a block around the code. Or a table embedding the code.

Any help is really appreciated.

And one more thing, whenever I run the above example on TexmakerX, I get an error Package

minted Error: You must invoke LaTeX with the -shell-escape flag

But when I run it in the cmd, using

pdflatex -shell-escape filename

it seems to work fine.

How can I make it run in Texmakerx?

share|improve this question
    
Please ask one question at a time. I have answered the part regarding the "block". I am posting a follow-up question regarding how to invoke -shell-escape in TeXStudio (the new name of TeXMakerX) –  hpesoj626 Feb 22 '13 at 18:09
    
I have posted the other part of the question here: How to invoke latex with the -shell-escape flag in TeXMakerX? –  hpesoj626 Feb 22 '13 at 18:24
add comment

1 Answer

up vote 2 down vote accepted

Do you want to achieve something like this?

enter image description here

Do you mean you want to put a frame around your code? You have to use the frame option. You can choose from the values none (the default), leftline, topline, bottomline, lines, single.

\documentclass[]{article}
\usepackage{minted}

%opening

\begin{document}

\begin{listing}[H]
\begin{minted}[frame=single]{js}
var http = require("http");
    http.createServer(function(request, response) {
        response.writeHead(200, {"Content-Type": "text/plain"});
        response.end();
    }).listen(8080);
\end{minted}
\caption{Example of a listing.}
\end{listing}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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