emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org Babel blocks exports dollar signs to LaTeX verbatim
@ 2015-08-18 16:13 Matthew MacLean
  2015-09-04 11:57 ` Alan Schmitt
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew MacLean @ 2015-08-18 16:13 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1139 bytes --]

When working with Org Babel source code blocks, if I have a dollar sign in
my code and export it to PDF using LaTeX, it appears to parse as an
internal link. (Maybe?)

This is what it looks like:
[image: Inline image 1]
That comes from the following source code block:

    #+BEGIN_SRC sql :eval no :var id=1
      SELECT * FROM blah
        WHERE id=$id
    #+END_SRC

The resulting LaTeX from the source code block is:

    \begin{minted}[]{sql}
    SELECT * FROM blah
      WHERE id=$id
    \end{minted}

I have verified that SQL is not the only block type to do this by having a
Ruby block with nothing except a "$" in it, and got the same result.

This happens as late as commit 682bb962f3934cd50d28a9b2d0b0e0fb85746a03
with Pygments 1.6+dfsg-1ubuntu1 and the Minted included with
texlive-latex-extra 2013.20140215-2 on Linux Mint 17.2 and Emacs 24.5.1
(x86_64).

I have attached my Org Mode config (Not the actual config, but a few setqs
and a list of things that customize spits out), the test Org file, its
output, as well as the PDF generated from that.

Is this a bug? Or is there something wrong with my configuration?

Thanks.

[-- Attachment #1.1.2: Type: text/html, Size: 1423 bytes --]

[-- Attachment #1.2: Screenshot from 2015-08-18 09:46:10.png --]
[-- Type: image/png, Size: 5794 bytes --]

[-- Attachment #2: config.el --]
[-- Type: text/x-emacs-lisp, Size: 2252 bytes --]

;; From my dotemacs
(setq-default indent-tabs-mode nil)
(setq org-src-fontify-natively t)
(setq org-export-latex-listings 'minted)

;; From customize
(list
 '(org-agenda-window-setup (quote current-window))
 '(org-babel-load-languages
   (quote
    ((emacs-lisp . t)
     (lisp . t)
     (dot . t)
     (java . t)
     (js . t)
     (http . t)
     (ruby . t)
     (sh . t)
     (C . t)
     (sql . t))))
 '(org-confirm-babel-evaluate nil)
 '(org-drill-optimal-factor-matrix
   (quote
    ((2
      (2.6 . 2.588))
     (1
      (2.36 . 3.86)
      (1.96 . 3.58)
      (2.5 . 4.0)))))
 '(org-export-backends (quote (ascii html icalendar latex man md odt)))
 '(org-export-latex-listings (quote minted) t)
 '(org-indirect-buffer-display (quote current-window))
 '(org-latex-listings (quote minted))
 '(org-latex-minted-langs
   (quote
    ((emacs-lisp "common-lisp")
     (sql "sql")
     (cc "c++")
     (cperl "perl")
     (shell-script "bash")
     (caml "ocaml")
     (lisp "common-lisp"))))
 '(org-latex-packages-alist (quote (("" "minted" t))))
 '(org-latex-pdf-process
   (quote
    ("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")))
 '(org-link-frame-setup
   (quote
    ((vm . vm-visit-folder-other-frame)
     (vm-imap . vm-visit-imap-folder-other-frame)
     (gnus . org-gnus-no-new-news)
     (file . find-file)
     (wl . wl-other-frame))))
 '(org-modules
   (quote
    (org-bbdb org-bibtex org-docview org-gnus org-info org-irc org-mhe org-rmail org-w3m org-drill)))
 '(org-src-fontify-natively t)
 '(org-src-lang-modes
   (quote
    (("ocaml" . tuareg)
     ("elisp" . emacs-lisp)
     ("ditaa" . artist)
     ("asymptote" . asy)
     ("dot" . fundamental)
     ("sqlite" . sql)
     ("calc" . fundamental)
     ("C" . c)
     ("cpp" . c++)
     ("screen" . shell-script)
     ("java" . java)
     ("http" . ob-http)
     ("C++" . c++))))
 '(org-src-window-setup (quote current-window))
 '(org-todo-keywords
   (quote
    ((sequence "TODO(t)" "|" "DONE(d)")
     (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
     (sequence "|" "CANCELLED(c)")))))

[-- Attachment #3: dollar.org --]
[-- Type: application/octet-stream, Size: 83 bytes --]

#+BEGIN_SRC sql :eval no :var id=1
  SELECT * FROM blah
    WHERE id=$id
#+END_SRC

[-- Attachment #4: dollar.tex --]
[-- Type: application/x-tex, Size: 711 bytes --]

[-- Attachment #5: dollar.pdf --]
[-- Type: application/pdf, Size: 41839 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Org Babel blocks exports dollar signs to LaTeX verbatim
  2015-08-18 16:13 Org Babel blocks exports dollar signs to LaTeX verbatim Matthew MacLean
@ 2015-09-04 11:57 ` Alan Schmitt
  2015-09-04 16:00   ` Matthew MacLean
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Schmitt @ 2015-09-04 11:57 UTC (permalink / raw)
  To: Matthew MacLean; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

(Still catching up on orgmode mail … sorry if you already found a way to
address the issue)

On 2015-08-18 18:13, Matthew MacLean <archenoth@gmail.com> writes:

> When working with Org Babel source code blocks, if I have a dollar sign in my
> code and export it to PDF using LaTeX, it appears to parse as an internal
> link. (Maybe?)
>
> This is what it looks like:
> Inline image 1
> That comes from the following source code block:
>
> #+BEGIN_SRC sql :eval no :var id=1
> SELECT * FROM blah
> WHERE id=$id
> #+END_SRC
>
> The resulting LaTeX from the source code block is:
>
> \begin{minted}[]{sql}
> SELECT * FROM blah
> WHERE id=$id
> \end{minted}
>
> I have verified that SQL is not the only block type to do this by having a
> Ruby block with nothing except a "$" in it, and got the same result.

These red boxes often come from signaling a syntax error from pygments,
which I confirmed by putting the code in a test.sql file and running:

% pygmentize -f latex test.sql
\begin{Verbatim}[commandchars=\\\{\}]
\PY{k}{SELECT} \PY{o}{*} \PY{k}{FROM} \PY{n}{blah}
\PY{k}{WHERE} \PY{n}{id}\PY{o}{=}\PY{err}{\PYZdl{}}\PY{n}{id}
\end{Verbatim}

You can see the “\PY{err}” that signals a parser error around the dollar
sign.

There are some solutions to hide these boxes here:
http://tex.stackexchange.com/questions/14166/red-box-drawn-around-question-mark-operator-in-minted-erlang-code

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated August 31, 2015, Mauna Loa Obs.):
377.82 ppm

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Org Babel blocks exports dollar signs to LaTeX verbatim
  2015-09-04 11:57 ` Alan Schmitt
@ 2015-09-04 16:00   ` Matthew MacLean
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew MacLean @ 2015-09-04 16:00 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2625 bytes --]

Ah, thanks! So it was configuration then...

I initially figured it was language-dependant, which was why I tried it in
Ruby, since "$" is a valid character in that language... What I didn't
anticipate was that the boxes came from intelligent-syntax checking--I
figured that it was just some sort of fancy character I was unfamiliar with
that needed to be escaped.

So, the way I fixed the issue in my Org file was to add the following to
override the syntax error checking:

    #+LATEX_HEADER: \expandafter\def\csname PY@tok@err\endcsname{}

It was recommended on that Stack Exchange answer not to do this, but we
aren't writing code directly in LaTeX, we're using Org mode..! That means
we don't really need error highlighting in our exporting, since that sort
of thing is already covered by existing language support.

On Fri, Sep 4, 2015 at 5:57 AM, Alan Schmitt <alan.schmitt@polytechnique.org
> wrote:

> (Still catching up on orgmode mail … sorry if you already found a way to
> address the issue)
>
> On 2015-08-18 18:13, Matthew MacLean <archenoth@gmail.com> writes:
>
> > When working with Org Babel source code blocks, if I have a dollar sign
> in my
> > code and export it to PDF using LaTeX, it appears to parse as an internal
> > link. (Maybe?)
> >
> > This is what it looks like:
> > Inline image 1
> > That comes from the following source code block:
> >
> > #+BEGIN_SRC sql :eval no :var id=1
> > SELECT * FROM blah
> > WHERE id=$id
> > #+END_SRC
> >
> > The resulting LaTeX from the source code block is:
> >
> > \begin{minted}[]{sql}
> > SELECT * FROM blah
> > WHERE id=$id
> > \end{minted}
> >
> > I have verified that SQL is not the only block type to do this by having
> a
> > Ruby block with nothing except a "$" in it, and got the same result.
>
> These red boxes often come from signaling a syntax error from pygments,
> which I confirmed by putting the code in a test.sql file and running:
>
> % pygmentize -f latex test.sql
> \begin{Verbatim}[commandchars=\\\{\}]
> \PY{k}{SELECT} \PY{o}{*} \PY{k}{FROM} \PY{n}{blah}
> \PY{k}{WHERE} \PY{n}{id}\PY{o}{=}\PY{err}{\PYZdl{}}\PY{n}{id}
> \end{Verbatim}
>
> You can see the “\PY{err}” that signals a parser error around the dollar
> sign.
>
> There are some solutions to hide these boxes here:
>
> http://tex.stackexchange.com/questions/14166/red-box-drawn-around-question-mark-operator-in-minted-erlang-code
>
> Best,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Last week athmospheric CO₂ average (Updated August 31, 2015, Mauna Loa
> Obs.):
> 377.82 ppm
>

[-- Attachment #2: Type: text/html, Size: 3504 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-04 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18 16:13 Org Babel blocks exports dollar signs to LaTeX verbatim Matthew MacLean
2015-09-04 11:57 ` Alan Schmitt
2015-09-04 16:00   ` Matthew MacLean

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).