LaTeX newcommand with verbatim or listings : problem with `#` (hash key)
I'm trying to define a macro with newcommand
using verbatim
or listings
environment. It seems that the hash key in #1
(standing for the argument) is escaped, due to verbatim
and listings
.
I'm new to macros, so I tried something simple : it works with begin{center} ... end{center}
.
documentclass[a4paper,oneside,11pt]{report}
newcommand{script}[1]{
begin{center}
#1
end{center}
}
begin{document}
script{blabla}
blibli
end{document}
When I replace center
with verbatim
, I get this error :
File ended while scanning use of @xverbatim.
or lstlisting
:
Text dropped after begin of listing
I didn't find anything on stackoverflow nor https://tex.stackexchange.com : what would you advise to use those environments in macros (newcommand
or maybe newenvironment
) ?
Thanks in advance
macros latex special-characters listings verbatim
add a comment |
I'm trying to define a macro with newcommand
using verbatim
or listings
environment. It seems that the hash key in #1
(standing for the argument) is escaped, due to verbatim
and listings
.
I'm new to macros, so I tried something simple : it works with begin{center} ... end{center}
.
documentclass[a4paper,oneside,11pt]{report}
newcommand{script}[1]{
begin{center}
#1
end{center}
}
begin{document}
script{blabla}
blibli
end{document}
When I replace center
with verbatim
, I get this error :
File ended while scanning use of @xverbatim.
or lstlisting
:
Text dropped after begin of listing
I didn't find anything on stackoverflow nor https://tex.stackexchange.com : what would you advise to use those environments in macros (newcommand
or maybe newenvironment
) ?
Thanks in advance
macros latex special-characters listings verbatim
1
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based onlistings
.
– Werner
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday
add a comment |
I'm trying to define a macro with newcommand
using verbatim
or listings
environment. It seems that the hash key in #1
(standing for the argument) is escaped, due to verbatim
and listings
.
I'm new to macros, so I tried something simple : it works with begin{center} ... end{center}
.
documentclass[a4paper,oneside,11pt]{report}
newcommand{script}[1]{
begin{center}
#1
end{center}
}
begin{document}
script{blabla}
blibli
end{document}
When I replace center
with verbatim
, I get this error :
File ended while scanning use of @xverbatim.
or lstlisting
:
Text dropped after begin of listing
I didn't find anything on stackoverflow nor https://tex.stackexchange.com : what would you advise to use those environments in macros (newcommand
or maybe newenvironment
) ?
Thanks in advance
macros latex special-characters listings verbatim
I'm trying to define a macro with newcommand
using verbatim
or listings
environment. It seems that the hash key in #1
(standing for the argument) is escaped, due to verbatim
and listings
.
I'm new to macros, so I tried something simple : it works with begin{center} ... end{center}
.
documentclass[a4paper,oneside,11pt]{report}
newcommand{script}[1]{
begin{center}
#1
end{center}
}
begin{document}
script{blabla}
blibli
end{document}
When I replace center
with verbatim
, I get this error :
File ended while scanning use of @xverbatim.
or lstlisting
:
Text dropped after begin of listing
I didn't find anything on stackoverflow nor https://tex.stackexchange.com : what would you advise to use those environments in macros (newcommand
or maybe newenvironment
) ?
Thanks in advance
macros latex special-characters listings verbatim
macros latex special-characters listings verbatim
asked yesterday
vvfflvvffl
437
437
1
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based onlistings
.
– Werner
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday
add a comment |
1
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based onlistings
.
– Werner
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday
1
1
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based on
listings
.– Werner
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based on
listings
.– Werner
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday
add a comment |
2 Answers
2
active
oldest
votes
Verbatim content is tricky. You have to ask yourself what the intent is. If it's printing code, then king of the hill would be listings
. I'd suggest that and define your own environment for large chunks of code-specific output.
Here's an example:
documentclass{article}
usepackage{listings}
lstnewenvironment{code}[1]
{lstset{#1}}% Add/update settings locally
{}
lstset{% Global options
frame = single,
basicstyle = ttfamilysmall,
language = PHP
}
begin{document}
My first PHP ``Hello World'' page:
begin{code}
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
end{code}
When you write lstinline!<title>PHP Test</test>!, it sets the textit{title} of the page.
end{document}
Thank you very much Werner, you convinced me to learn more aboutlistings
. Didn't know oflstinline
. Could you just explain the syntax of{lstset{#1}}
: does it mean I can add an option as argument?
– vvffl
19 hours ago
1
@vvffl: Yes. I definedcode
as an environment that can take an optional argument. So you can call (say)begin{code}[language = bash]
...end{code}
to switch thelanguage
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).
– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which usesaccsupp
.
– Werner
19 hours ago
|
show 2 more comments
Found a workaround for verbatim
with verb
command, and using tilde as delimiter (if I want to use tilde inside the script I have to use textasciitilde
):
documentclass{article}
newcommand{scr}[1]{
begin{minipage}{0.9textwidth}
fbox{
parbox{textwidth}{
verb~#1~ % <-- HERE
}
}
end{minipage}
}
begin{document}
scr{Some script code here...
here a tilde : textasciitilde
}
end{document}
But nothing for listings
...
EDIT :
I've just noticed that this workaround doesn't keep the "automatic" character escaping, so it's not what I was looking for. I'd like to be able to paste code without escaping special chars.
This does not work. Within averbatim
setting (either within theverbatim
environment orverb
) macros liketextasciitilde
are not expanded to their meaning sinceis changed to represent a character. As such, your output should contain
textasciitilde
, not~
.
– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f54251182%2flatex-newcommand-with-verbatim-or-listings-problem-with-hash-key%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Verbatim content is tricky. You have to ask yourself what the intent is. If it's printing code, then king of the hill would be listings
. I'd suggest that and define your own environment for large chunks of code-specific output.
Here's an example:
documentclass{article}
usepackage{listings}
lstnewenvironment{code}[1]
{lstset{#1}}% Add/update settings locally
{}
lstset{% Global options
frame = single,
basicstyle = ttfamilysmall,
language = PHP
}
begin{document}
My first PHP ``Hello World'' page:
begin{code}
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
end{code}
When you write lstinline!<title>PHP Test</test>!, it sets the textit{title} of the page.
end{document}
Thank you very much Werner, you convinced me to learn more aboutlistings
. Didn't know oflstinline
. Could you just explain the syntax of{lstset{#1}}
: does it mean I can add an option as argument?
– vvffl
19 hours ago
1
@vvffl: Yes. I definedcode
as an environment that can take an optional argument. So you can call (say)begin{code}[language = bash]
...end{code}
to switch thelanguage
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).
– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which usesaccsupp
.
– Werner
19 hours ago
|
show 2 more comments
Verbatim content is tricky. You have to ask yourself what the intent is. If it's printing code, then king of the hill would be listings
. I'd suggest that and define your own environment for large chunks of code-specific output.
Here's an example:
documentclass{article}
usepackage{listings}
lstnewenvironment{code}[1]
{lstset{#1}}% Add/update settings locally
{}
lstset{% Global options
frame = single,
basicstyle = ttfamilysmall,
language = PHP
}
begin{document}
My first PHP ``Hello World'' page:
begin{code}
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
end{code}
When you write lstinline!<title>PHP Test</test>!, it sets the textit{title} of the page.
end{document}
Thank you very much Werner, you convinced me to learn more aboutlistings
. Didn't know oflstinline
. Could you just explain the syntax of{lstset{#1}}
: does it mean I can add an option as argument?
– vvffl
19 hours ago
1
@vvffl: Yes. I definedcode
as an environment that can take an optional argument. So you can call (say)begin{code}[language = bash]
...end{code}
to switch thelanguage
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).
– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which usesaccsupp
.
– Werner
19 hours ago
|
show 2 more comments
Verbatim content is tricky. You have to ask yourself what the intent is. If it's printing code, then king of the hill would be listings
. I'd suggest that and define your own environment for large chunks of code-specific output.
Here's an example:
documentclass{article}
usepackage{listings}
lstnewenvironment{code}[1]
{lstset{#1}}% Add/update settings locally
{}
lstset{% Global options
frame = single,
basicstyle = ttfamilysmall,
language = PHP
}
begin{document}
My first PHP ``Hello World'' page:
begin{code}
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
end{code}
When you write lstinline!<title>PHP Test</test>!, it sets the textit{title} of the page.
end{document}
Verbatim content is tricky. You have to ask yourself what the intent is. If it's printing code, then king of the hill would be listings
. I'd suggest that and define your own environment for large chunks of code-specific output.
Here's an example:
documentclass{article}
usepackage{listings}
lstnewenvironment{code}[1]
{lstset{#1}}% Add/update settings locally
{}
lstset{% Global options
frame = single,
basicstyle = ttfamilysmall,
language = PHP
}
begin{document}
My first PHP ``Hello World'' page:
begin{code}
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
end{code}
When you write lstinline!<title>PHP Test</test>!, it sets the textit{title} of the page.
end{document}
answered 23 hours ago
WernerWerner
7,86142644
7,86142644
Thank you very much Werner, you convinced me to learn more aboutlistings
. Didn't know oflstinline
. Could you just explain the syntax of{lstset{#1}}
: does it mean I can add an option as argument?
– vvffl
19 hours ago
1
@vvffl: Yes. I definedcode
as an environment that can take an optional argument. So you can call (say)begin{code}[language = bash]
...end{code}
to switch thelanguage
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).
– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which usesaccsupp
.
– Werner
19 hours ago
|
show 2 more comments
Thank you very much Werner, you convinced me to learn more aboutlistings
. Didn't know oflstinline
. Could you just explain the syntax of{lstset{#1}}
: does it mean I can add an option as argument?
– vvffl
19 hours ago
1
@vvffl: Yes. I definedcode
as an environment that can take an optional argument. So you can call (say)begin{code}[language = bash]
...end{code}
to switch thelanguage
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).
– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which usesaccsupp
.
– Werner
19 hours ago
Thank you very much Werner, you convinced me to learn more about
listings
. Didn't know of lstinline
. Could you just explain the syntax of {lstset{#1}}
: does it mean I can add an option as argument?– vvffl
19 hours ago
Thank you very much Werner, you convinced me to learn more about
listings
. Didn't know of lstinline
. Could you just explain the syntax of {lstset{#1}}
: does it mean I can add an option as argument?– vvffl
19 hours ago
1
1
@vvffl: Yes. I defined
code
as an environment that can take an optional argument. So you can call (say) begin{code}[language = bash]
...end{code}
to switch the language
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).– Werner
19 hours ago
@vvffl: Yes. I defined
code
as an environment that can take an optional argument. So you can call (say) begin{code}[language = bash]
...end{code}
to switch the language
. It would probably be ideal for you to define a style depending on the language (styles include colour and other formatting specifications).– Werner
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
Thanks, it's exactly what I thought (I have somewhere in my tex files an old paper where I used custom syntax color for xml, so I'm going to 'grep' that first). So macros aren't that difficult, but the syntax still looks weird for me.
– vvffl
19 hours ago
1
1
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
@vvffl: This is a common requirement, but it's not well-supported. See Viewer-independent copyable spaces at the beginning of a line? The fact that the output (in the resulting PDF) does not include the spaces, they aren't selectable for copy-and-paste. As such, indentation is not preserved. The intent of (La)TeX is to produce beautiful documents and therefore might not fully support the "reverse" where that content is copied/pasted elsewhere.
– Werner
19 hours ago
1
1
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which uses
accsupp
.– Werner
19 hours ago
@vvffl: You can try Copy-pasting leading whitespace and blank lines in listings package (PDF), which uses
accsupp
.– Werner
19 hours ago
|
show 2 more comments
Found a workaround for verbatim
with verb
command, and using tilde as delimiter (if I want to use tilde inside the script I have to use textasciitilde
):
documentclass{article}
newcommand{scr}[1]{
begin{minipage}{0.9textwidth}
fbox{
parbox{textwidth}{
verb~#1~ % <-- HERE
}
}
end{minipage}
}
begin{document}
scr{Some script code here...
here a tilde : textasciitilde
}
end{document}
But nothing for listings
...
EDIT :
I've just noticed that this workaround doesn't keep the "automatic" character escaping, so it's not what I was looking for. I'd like to be able to paste code without escaping special chars.
This does not work. Within averbatim
setting (either within theverbatim
environment orverb
) macros liketextasciitilde
are not expanded to their meaning sinceis changed to represent a character. As such, your output should contain
textasciitilde
, not~
.
– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
add a comment |
Found a workaround for verbatim
with verb
command, and using tilde as delimiter (if I want to use tilde inside the script I have to use textasciitilde
):
documentclass{article}
newcommand{scr}[1]{
begin{minipage}{0.9textwidth}
fbox{
parbox{textwidth}{
verb~#1~ % <-- HERE
}
}
end{minipage}
}
begin{document}
scr{Some script code here...
here a tilde : textasciitilde
}
end{document}
But nothing for listings
...
EDIT :
I've just noticed that this workaround doesn't keep the "automatic" character escaping, so it's not what I was looking for. I'd like to be able to paste code without escaping special chars.
This does not work. Within averbatim
setting (either within theverbatim
environment orverb
) macros liketextasciitilde
are not expanded to their meaning sinceis changed to represent a character. As such, your output should contain
textasciitilde
, not~
.
– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
add a comment |
Found a workaround for verbatim
with verb
command, and using tilde as delimiter (if I want to use tilde inside the script I have to use textasciitilde
):
documentclass{article}
newcommand{scr}[1]{
begin{minipage}{0.9textwidth}
fbox{
parbox{textwidth}{
verb~#1~ % <-- HERE
}
}
end{minipage}
}
begin{document}
scr{Some script code here...
here a tilde : textasciitilde
}
end{document}
But nothing for listings
...
EDIT :
I've just noticed that this workaround doesn't keep the "automatic" character escaping, so it's not what I was looking for. I'd like to be able to paste code without escaping special chars.
Found a workaround for verbatim
with verb
command, and using tilde as delimiter (if I want to use tilde inside the script I have to use textasciitilde
):
documentclass{article}
newcommand{scr}[1]{
begin{minipage}{0.9textwidth}
fbox{
parbox{textwidth}{
verb~#1~ % <-- HERE
}
}
end{minipage}
}
begin{document}
scr{Some script code here...
here a tilde : textasciitilde
}
end{document}
But nothing for listings
...
EDIT :
I've just noticed that this workaround doesn't keep the "automatic" character escaping, so it's not what I was looking for. I'd like to be able to paste code without escaping special chars.
edited yesterday
answered yesterday
vvfflvvffl
437
437
This does not work. Within averbatim
setting (either within theverbatim
environment orverb
) macros liketextasciitilde
are not expanded to their meaning sinceis changed to represent a character. As such, your output should contain
textasciitilde
, not~
.
– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
add a comment |
This does not work. Within averbatim
setting (either within theverbatim
environment orverb
) macros liketextasciitilde
are not expanded to their meaning sinceis changed to represent a character. As such, your output should contain
textasciitilde
, not~
.
– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
This does not work. Within a
verbatim
setting (either within the verbatim
environment or verb
) macros like textasciitilde
are not expanded to their meaning since
is changed to represent a character. As such, your output should contain textasciitilde
, not ~
.– Werner
yesterday
This does not work. Within a
verbatim
setting (either within the verbatim
environment or verb
) macros like textasciitilde
are not expanded to their meaning since
is changed to represent a character. As such, your output should contain textasciitilde
, not ~
.– Werner
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
Thanks for your reply. Actually it does work on my install... Don't know how nor why!
– vvffl
yesterday
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f54251182%2flatex-newcommand-with-verbatim-or-listings-problem-with-hash-key%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
1
What is the aim here? Verbatim content cannot be passed as an argument to other macros.
– Werner
yesterday
I'd like 1) to paste scripts and code without having to escape characters 2) make a minipage or sthg else, maybe a box, to distinguish between code and normal text in the page.
– vvffl
yesterday
By "scripts of code" are you referring to the actual code? I would suggest writing your own environment based on
listings
.– Werner
yesterday
I'm making a tutorial in which I use PHP, bash, Sparql. But I'd like to paste any text with special chars. What do you mean with > writing your own environment based on listings. ? Is there a simple manner to do so (haven't found yet)?
– vvffl
yesterday