Escaping $ in listings environment Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraUse $ in lstlistingIs there a way to tell listings what to do immediately after escaping?Escaping in lstinlineProblems When Escaping from ListingsEscaping from the escaping hell“Listings” environment for GAPtex4ht and listings: lines don't break when using escapeinsideInline escaping myVariable Escaping underscorelistings: NOT escaping formulaslstnewenvironment/lstset : using colors conditionally emph/emphstyle - SAS: (in=_x) versus if x in (1,2)
Mistake in years of experience in resume?
Is it acceptable to use working hours to read general interest books?
How would I use different systems of magic when they are capable of the same effects?
Can I criticise the more senior developers around me for not writing clean code?
std::is_constructible on incomplete types
Protagonist's race is hidden - should I reveal it?
Is Bran literally the world's memory?
c++ diamond problem - How to call base method only once
How to open locks without disable device?
Is this homebrew racial feat, Stonehide, balanced?
How long after the last departure shall the airport stay open for an emergency return?
How to translate "red flag" into Spanish?
A Paper Record is What I Hamper
Could Neutrino technically as side-effect, incentivize centralization of the bitcoin network?
How to not starve gigantic beasts
What is the term for a person whose job is to place products on shelves in stores?
Is accepting an invalid credit card number a security issue?
Implementing 3DES algorithm in Java: is my code secure?
"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?
How to get even lighting when using flash for group photos near wall?
"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"
Suing a Police Officer Instead of the Police Department
All ASCII characters with a given bit count
What is this word supposed to be?
Escaping $ in listings environment
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraUse $ in lstlistingIs there a way to tell listings what to do immediately after escaping?Escaping in lstinlineProblems When Escaping from ListingsEscaping from the escaping hell“Listings” environment for GAPtex4ht and listings: lines don't break when using escapeinsideInline escaping myVariable Escaping underscorelistings: NOT escaping formulaslstnewenvironment/lstset : using colors conditionally emph/emphstyle - SAS: (in=_x) versus if x in (1,2)
I'm trying to escape the dollar sign within listings for TeX language but it is not working. I have tried this post without any success.
This is the MWE:
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
newcommandlatexstylelstset
language=TeX,
basicstyle=scriptsizettfamily,
mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=begin, addplot, addlegendentry, documentclass, usepackage, usetikzlibrary, usepgfplotslibrary, pgfplotsset, nextlist, coordinate small, draw,
% Python environment
lstnewenvironmentlatex[1][mathescape]
latexstyle
lstset#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument
listings
add a comment |
I'm trying to escape the dollar sign within listings for TeX language but it is not working. I have tried this post without any success.
This is the MWE:
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
newcommandlatexstylelstset
language=TeX,
basicstyle=scriptsizettfamily,
mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=begin, addplot, addlegendentry, documentclass, usepackage, usetikzlibrary, usepgfplotslibrary, pgfplotsset, nextlist, coordinate small, draw,
% Python environment
lstnewenvironmentlatex[1][mathescape]
latexstyle
lstset#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument
listings
You are the culprit: since you havemathescape=true, TeX follows the instructions.
– egreg
2 days ago
add a comment |
I'm trying to escape the dollar sign within listings for TeX language but it is not working. I have tried this post without any success.
This is the MWE:
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
newcommandlatexstylelstset
language=TeX,
basicstyle=scriptsizettfamily,
mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=begin, addplot, addlegendentry, documentclass, usepackage, usetikzlibrary, usepgfplotslibrary, pgfplotsset, nextlist, coordinate small, draw,
% Python environment
lstnewenvironmentlatex[1][mathescape]
latexstyle
lstset#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument
listings
I'm trying to escape the dollar sign within listings for TeX language but it is not working. I have tried this post without any success.
This is the MWE:
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
newcommandlatexstylelstset
language=TeX,
basicstyle=scriptsizettfamily,
mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=begin, addplot, addlegendentry, documentclass, usepackage, usetikzlibrary, usepgfplotslibrary, pgfplotsset, nextlist, coordinate small, draw,
% Python environment
lstnewenvironmentlatex[1][mathescape]
latexstyle
lstset#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument
listings
listings
asked 2 days ago
aaragonaaragon
1,23721029
1,23721029
You are the culprit: since you havemathescape=true, TeX follows the instructions.
– egreg
2 days ago
add a comment |
You are the culprit: since you havemathescape=true, TeX follows the instructions.
– egreg
2 days ago
You are the culprit: since you have
mathescape=true, TeX follows the instructions.– egreg
2 days ago
You are the culprit: since you have
mathescape=true, TeX follows the instructions.– egreg
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
You're setting mathescape=true twice. You're possibly misunderstanding its meaning: with mathescape=true, listings will act as if a TeX math formula is meant when you type something like $alpha$ (so printing a math alpha). I don't think you want it when typesetting a listing like this.
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
lstdefinestylelatexstyle
language=TeX,
basicstyle=scriptsizettfamily,
% mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=
begin,
addplot,
addlegendentry,
documentclass,
usepackage,
usetikzlibrary,
usepgfplotslibrary,
pgfplotsset,
nextlist,
coordinate small,
draw
,
% latexn environment
lstnewenvironmentlatex[1][]
lstsetstyle=latexstyle,#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument

add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486026%2fescaping-in-listings-environment%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're setting mathescape=true twice. You're possibly misunderstanding its meaning: with mathescape=true, listings will act as if a TeX math formula is meant when you type something like $alpha$ (so printing a math alpha). I don't think you want it when typesetting a listing like this.
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
lstdefinestylelatexstyle
language=TeX,
basicstyle=scriptsizettfamily,
% mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=
begin,
addplot,
addlegendentry,
documentclass,
usepackage,
usetikzlibrary,
usepgfplotslibrary,
pgfplotsset,
nextlist,
coordinate small,
draw
,
% latexn environment
lstnewenvironmentlatex[1][]
lstsetstyle=latexstyle,#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument

add a comment |
You're setting mathescape=true twice. You're possibly misunderstanding its meaning: with mathescape=true, listings will act as if a TeX math formula is meant when you type something like $alpha$ (so printing a math alpha). I don't think you want it when typesetting a listing like this.
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
lstdefinestylelatexstyle
language=TeX,
basicstyle=scriptsizettfamily,
% mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=
begin,
addplot,
addlegendentry,
documentclass,
usepackage,
usetikzlibrary,
usepgfplotslibrary,
pgfplotsset,
nextlist,
coordinate small,
draw
,
% latexn environment
lstnewenvironmentlatex[1][]
lstsetstyle=latexstyle,#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument

add a comment |
You're setting mathescape=true twice. You're possibly misunderstanding its meaning: with mathescape=true, listings will act as if a TeX math formula is meant when you type something like $alpha$ (so printing a math alpha). I don't think you want it when typesetting a listing like this.
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
lstdefinestylelatexstyle
language=TeX,
basicstyle=scriptsizettfamily,
% mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=
begin,
addplot,
addlegendentry,
documentclass,
usepackage,
usetikzlibrary,
usepgfplotslibrary,
pgfplotsset,
nextlist,
coordinate small,
draw
,
% latexn environment
lstnewenvironmentlatex[1][]
lstsetstyle=latexstyle,#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument

You're setting mathescape=true twice. You're possibly misunderstanding its meaning: with mathescape=true, listings will act as if a TeX math formula is meant when you type something like $alpha$ (so printing a math alpha). I don't think you want it when typesetting a listing like this.
documentclass[border=10pt 10pt 10pt 10pt]standalone
usepackage[dvipsnames]xcolor
usepackagelistings
% Python style for highlighting
lstdefinestylelatexstyle
language=TeX,
basicstyle=scriptsizettfamily,
% mathescape=true,
keywordstyle=colorMidnightBluebfseries,
morekeywords=
begin,
addplot,
addlegendentry,
documentclass,
usepackage,
usetikzlibrary,
usepgfplotslibrary,
pgfplotsset,
nextlist,
coordinate small,
draw
,
% latexn environment
lstnewenvironmentlatex[1][]
lstsetstyle=latexstyle,#1
begindocument
beginlatex
begintikzpicture
beginloglogaxis
addplot+ [ultra thick, dotted] table[]
10 0.2
100 0.1
1000 0.05
coordinate [pos=0.15] (A)
coordinate [pos=0.25] (B);
addlegendentrylegend 1
coordinate (A') at ($(A)!3pt!90:(B)$);
coordinate (B') at ($(B)!3pt!270:(A)$);
draw (A')-|(B') node[pos=0.25,above]$1$
node[pos=0.75,right]$alpha$;
draw [shorten <=-3pt,shorten >=-3pt] (A') -- (B');
endloglogaxis
endtikzpicture
endlatex
enddocument

edited 2 days ago
siracusa
5,36511429
5,36511429
answered 2 days ago
egregegreg
736k8919353261
736k8919353261
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486026%2fescaping-in-listings-environment%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are the culprit: since you have
mathescape=true, TeX follows the instructions.– egreg
2 days ago