How can we Define our own Simple Environment for Source Code?
Inside of our document we wish to define a new environment for blocks of source code
newenvironment{srcblock}%
% Define the environment
Later, we will use the environment:
begin{srcblock} % use the environment
% source code here
end{srcblock}
We seek the following behavior:
- Each line in a src code block is numbered
- The font used for a src code block is monospaced
- A border is drawn around a code code block, much like
fboxdoes - Each code block "floats" to a position so that it will fit all on one page.
environments sourcecode fbox
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Inside of our document we wish to define a new environment for blocks of source code
newenvironment{srcblock}%
% Define the environment
Later, we will use the environment:
begin{srcblock} % use the environment
% source code here
end{srcblock}
We seek the following behavior:
- Each line in a src code block is numbered
- The font used for a src code block is monospaced
- A border is drawn around a code code block, much like
fboxdoes - Each code block "floats" to a position so that it will fit all on one page.
environments sourcecode fbox
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What willsrcblockcontain in terms of characters?verbatim-like content, perhaps (symbols like#,_,$,^, ...)?
– Werner
3 hours ago
Did you already check thelistingspackage? This should be straight-forward with it. Just read the manual.
– Martin Scharrer♦
3 hours ago
add a comment |
Inside of our document we wish to define a new environment for blocks of source code
newenvironment{srcblock}%
% Define the environment
Later, we will use the environment:
begin{srcblock} % use the environment
% source code here
end{srcblock}
We seek the following behavior:
- Each line in a src code block is numbered
- The font used for a src code block is monospaced
- A border is drawn around a code code block, much like
fboxdoes - Each code block "floats" to a position so that it will fit all on one page.
environments sourcecode fbox
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Inside of our document we wish to define a new environment for blocks of source code
newenvironment{srcblock}%
% Define the environment
Later, we will use the environment:
begin{srcblock} % use the environment
% source code here
end{srcblock}
We seek the following behavior:
- Each line in a src code block is numbered
- The font used for a src code block is monospaced
- A border is drawn around a code code block, much like
fboxdoes - Each code block "floats" to a position so that it will fit all on one page.
environments sourcecode fbox
environments sourcecode fbox
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago
IdleCustardIdleCustard
561
561
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
IdleCustard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What willsrcblockcontain in terms of characters?verbatim-like content, perhaps (symbols like#,_,$,^, ...)?
– Werner
3 hours ago
Did you already check thelistingspackage? This should be straight-forward with it. Just read the manual.
– Martin Scharrer♦
3 hours ago
add a comment |
What willsrcblockcontain in terms of characters?verbatim-like content, perhaps (symbols like#,_,$,^, ...)?
– Werner
3 hours ago
Did you already check thelistingspackage? This should be straight-forward with it. Just read the manual.
– Martin Scharrer♦
3 hours ago
What will
srcblock contain in terms of characters? verbatim-like content, perhaps (symbols like #, _, $, ^, ...)?– Werner
3 hours ago
What will
srcblock contain in terms of characters? verbatim-like content, perhaps (symbols like #, _, $, ^, ...)?– Werner
3 hours ago
Did you already check the
listings package? This should be straight-forward with it. Just read the manual.– Martin Scharrer♦
3 hours ago
Did you already check the
listings package? This should be straight-forward with it. Just read the manual.– Martin Scharrer♦
3 hours ago
add a comment |
2 Answers
2
active
oldest
votes
Variation on my answer here: Seemingly trivial: verbatim, newenvironment, and colorbox. It requires a small modification to my verbatimbox package.
documentclass{article}
usepackage{xcolor,caption,lipsum}
usepackage{verbatimbox}
makeatletter
newenvironment{cverbbox}[5]{%
setcounter{VerbboxLineNo}{0}%
defverbatim@processline{%
% THE FIRST #1 ACCOUNTS FOR NON-PRINTING COMMANDS; THE SECOND #1 IS FOR
% PRINTED OPTIONAL MATERIAL
{addtocounter{VerbboxLineNo}{1}%
#1setbox0=hbox{#1theverbatim@line}%
hsize=wd0 theverbatim@linepar}}%
@minipagetrue%
@tempswatrue%
globaledefsv@name{@macro@name{#2}}%
globaledefcverbboxColor{#4}%
globaledefcverbboxFColor{#5}%
@ifundefined{sv@name content}{%
expandafternewsaveboxexpandafter{csnamesv@name contentendcsname}%
}%
expandafterglobalexpandafteredefcsnamesv@nameendcsname{usebox{%
csnamesv@name contentendcsname}}%
setbox0=vboxbgroupcolor{#3} verbatim
}
{%
endverbatim%
unskipsetbox0=lastbox %
egroup%
setbox1=hbox{%
colorbox{cverbboxColor}{box0}}%
globalsbox{csnamesv@name contentendcsname}%
{fboxsep=fboxrulecolorbox{cverbboxFColor}{box1}}%
}
makeatother
fboxrule=1ptfboxsep=3ptrelax
begin{document}
lipsum[1]
begin{figure*}[ht]
begin{cverbbox}[textcolor{black}{scriptsizetheVerbboxLineNo~~}]{mycvbox}{red!80}{blue!10}{cyan}
verbatim <Text>
Here
%$#@&^* macros
xa
end{cverbbox}
centerline{mycvbox}
caption*{My code chunk}
end{figure*}
lipsum[2]
end{document}

add a comment |
This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like
fboxdoes (with top caption inside usingstdcaption, for a botom caption outside the box usecaption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

documentclass[a6paper]{article}
usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
pagestyle{empty}
usepackage{lipsum}
letstdcaptioncaption
setcounter{totalnumber}{1}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
begin{document}
begin{fancycode}
stdcaption[Basic Structure]{The basic structure of a LaTeX document.}
begin{minted}[linenos,bgcolor=orange!05]{latex}
documentclass{article}
begin{document}
end{document}
end{minted}
end{fancycode}
begin{fancycode}
stdcaption[Preamble]{The LaTeX preamble to do a texttt{fancycode}.}
begin{minted}[linenos,bgcolor=cyan!10]{latex}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
end{minted}
end{fancycode}
lipsum[1-2]
listof{fancycode}{Code examples}
end{document}
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
});
}
});
IdleCustard is a new contributor. Be nice, and check out our Code of Conduct.
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%2f469041%2fhow-can-we-define-our-own-simple-environment-for-source-code%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
Variation on my answer here: Seemingly trivial: verbatim, newenvironment, and colorbox. It requires a small modification to my verbatimbox package.
documentclass{article}
usepackage{xcolor,caption,lipsum}
usepackage{verbatimbox}
makeatletter
newenvironment{cverbbox}[5]{%
setcounter{VerbboxLineNo}{0}%
defverbatim@processline{%
% THE FIRST #1 ACCOUNTS FOR NON-PRINTING COMMANDS; THE SECOND #1 IS FOR
% PRINTED OPTIONAL MATERIAL
{addtocounter{VerbboxLineNo}{1}%
#1setbox0=hbox{#1theverbatim@line}%
hsize=wd0 theverbatim@linepar}}%
@minipagetrue%
@tempswatrue%
globaledefsv@name{@macro@name{#2}}%
globaledefcverbboxColor{#4}%
globaledefcverbboxFColor{#5}%
@ifundefined{sv@name content}{%
expandafternewsaveboxexpandafter{csnamesv@name contentendcsname}%
}%
expandafterglobalexpandafteredefcsnamesv@nameendcsname{usebox{%
csnamesv@name contentendcsname}}%
setbox0=vboxbgroupcolor{#3} verbatim
}
{%
endverbatim%
unskipsetbox0=lastbox %
egroup%
setbox1=hbox{%
colorbox{cverbboxColor}{box0}}%
globalsbox{csnamesv@name contentendcsname}%
{fboxsep=fboxrulecolorbox{cverbboxFColor}{box1}}%
}
makeatother
fboxrule=1ptfboxsep=3ptrelax
begin{document}
lipsum[1]
begin{figure*}[ht]
begin{cverbbox}[textcolor{black}{scriptsizetheVerbboxLineNo~~}]{mycvbox}{red!80}{blue!10}{cyan}
verbatim <Text>
Here
%$#@&^* macros
xa
end{cverbbox}
centerline{mycvbox}
caption*{My code chunk}
end{figure*}
lipsum[2]
end{document}

add a comment |
Variation on my answer here: Seemingly trivial: verbatim, newenvironment, and colorbox. It requires a small modification to my verbatimbox package.
documentclass{article}
usepackage{xcolor,caption,lipsum}
usepackage{verbatimbox}
makeatletter
newenvironment{cverbbox}[5]{%
setcounter{VerbboxLineNo}{0}%
defverbatim@processline{%
% THE FIRST #1 ACCOUNTS FOR NON-PRINTING COMMANDS; THE SECOND #1 IS FOR
% PRINTED OPTIONAL MATERIAL
{addtocounter{VerbboxLineNo}{1}%
#1setbox0=hbox{#1theverbatim@line}%
hsize=wd0 theverbatim@linepar}}%
@minipagetrue%
@tempswatrue%
globaledefsv@name{@macro@name{#2}}%
globaledefcverbboxColor{#4}%
globaledefcverbboxFColor{#5}%
@ifundefined{sv@name content}{%
expandafternewsaveboxexpandafter{csnamesv@name contentendcsname}%
}%
expandafterglobalexpandafteredefcsnamesv@nameendcsname{usebox{%
csnamesv@name contentendcsname}}%
setbox0=vboxbgroupcolor{#3} verbatim
}
{%
endverbatim%
unskipsetbox0=lastbox %
egroup%
setbox1=hbox{%
colorbox{cverbboxColor}{box0}}%
globalsbox{csnamesv@name contentendcsname}%
{fboxsep=fboxrulecolorbox{cverbboxFColor}{box1}}%
}
makeatother
fboxrule=1ptfboxsep=3ptrelax
begin{document}
lipsum[1]
begin{figure*}[ht]
begin{cverbbox}[textcolor{black}{scriptsizetheVerbboxLineNo~~}]{mycvbox}{red!80}{blue!10}{cyan}
verbatim <Text>
Here
%$#@&^* macros
xa
end{cverbbox}
centerline{mycvbox}
caption*{My code chunk}
end{figure*}
lipsum[2]
end{document}

add a comment |
Variation on my answer here: Seemingly trivial: verbatim, newenvironment, and colorbox. It requires a small modification to my verbatimbox package.
documentclass{article}
usepackage{xcolor,caption,lipsum}
usepackage{verbatimbox}
makeatletter
newenvironment{cverbbox}[5]{%
setcounter{VerbboxLineNo}{0}%
defverbatim@processline{%
% THE FIRST #1 ACCOUNTS FOR NON-PRINTING COMMANDS; THE SECOND #1 IS FOR
% PRINTED OPTIONAL MATERIAL
{addtocounter{VerbboxLineNo}{1}%
#1setbox0=hbox{#1theverbatim@line}%
hsize=wd0 theverbatim@linepar}}%
@minipagetrue%
@tempswatrue%
globaledefsv@name{@macro@name{#2}}%
globaledefcverbboxColor{#4}%
globaledefcverbboxFColor{#5}%
@ifundefined{sv@name content}{%
expandafternewsaveboxexpandafter{csnamesv@name contentendcsname}%
}%
expandafterglobalexpandafteredefcsnamesv@nameendcsname{usebox{%
csnamesv@name contentendcsname}}%
setbox0=vboxbgroupcolor{#3} verbatim
}
{%
endverbatim%
unskipsetbox0=lastbox %
egroup%
setbox1=hbox{%
colorbox{cverbboxColor}{box0}}%
globalsbox{csnamesv@name contentendcsname}%
{fboxsep=fboxrulecolorbox{cverbboxFColor}{box1}}%
}
makeatother
fboxrule=1ptfboxsep=3ptrelax
begin{document}
lipsum[1]
begin{figure*}[ht]
begin{cverbbox}[textcolor{black}{scriptsizetheVerbboxLineNo~~}]{mycvbox}{red!80}{blue!10}{cyan}
verbatim <Text>
Here
%$#@&^* macros
xa
end{cverbbox}
centerline{mycvbox}
caption*{My code chunk}
end{figure*}
lipsum[2]
end{document}

Variation on my answer here: Seemingly trivial: verbatim, newenvironment, and colorbox. It requires a small modification to my verbatimbox package.
documentclass{article}
usepackage{xcolor,caption,lipsum}
usepackage{verbatimbox}
makeatletter
newenvironment{cverbbox}[5]{%
setcounter{VerbboxLineNo}{0}%
defverbatim@processline{%
% THE FIRST #1 ACCOUNTS FOR NON-PRINTING COMMANDS; THE SECOND #1 IS FOR
% PRINTED OPTIONAL MATERIAL
{addtocounter{VerbboxLineNo}{1}%
#1setbox0=hbox{#1theverbatim@line}%
hsize=wd0 theverbatim@linepar}}%
@minipagetrue%
@tempswatrue%
globaledefsv@name{@macro@name{#2}}%
globaledefcverbboxColor{#4}%
globaledefcverbboxFColor{#5}%
@ifundefined{sv@name content}{%
expandafternewsaveboxexpandafter{csnamesv@name contentendcsname}%
}%
expandafterglobalexpandafteredefcsnamesv@nameendcsname{usebox{%
csnamesv@name contentendcsname}}%
setbox0=vboxbgroupcolor{#3} verbatim
}
{%
endverbatim%
unskipsetbox0=lastbox %
egroup%
setbox1=hbox{%
colorbox{cverbboxColor}{box0}}%
globalsbox{csnamesv@name contentendcsname}%
{fboxsep=fboxrulecolorbox{cverbboxFColor}{box1}}%
}
makeatother
fboxrule=1ptfboxsep=3ptrelax
begin{document}
lipsum[1]
begin{figure*}[ht]
begin{cverbbox}[textcolor{black}{scriptsizetheVerbboxLineNo~~}]{mycvbox}{red!80}{blue!10}{cyan}
verbatim <Text>
Here
%$#@&^* macros
xa
end{cverbbox}
centerline{mycvbox}
caption*{My code chunk}
end{figure*}
lipsum[2]
end{document}

answered 3 hours ago
Steven B. SegletesSteven B. Segletes
153k9193400
153k9193400
add a comment |
add a comment |
This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like
fboxdoes (with top caption inside usingstdcaption, for a botom caption outside the box usecaption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

documentclass[a6paper]{article}
usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
pagestyle{empty}
usepackage{lipsum}
letstdcaptioncaption
setcounter{totalnumber}{1}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
begin{document}
begin{fancycode}
stdcaption[Basic Structure]{The basic structure of a LaTeX document.}
begin{minted}[linenos,bgcolor=orange!05]{latex}
documentclass{article}
begin{document}
end{document}
end{minted}
end{fancycode}
begin{fancycode}
stdcaption[Preamble]{The LaTeX preamble to do a texttt{fancycode}.}
begin{minted}[linenos,bgcolor=cyan!10]{latex}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
end{minted}
end{fancycode}
lipsum[1-2]
listof{fancycode}{Code examples}
end{document}
add a comment |
This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like
fboxdoes (with top caption inside usingstdcaption, for a botom caption outside the box usecaption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

documentclass[a6paper]{article}
usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
pagestyle{empty}
usepackage{lipsum}
letstdcaptioncaption
setcounter{totalnumber}{1}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
begin{document}
begin{fancycode}
stdcaption[Basic Structure]{The basic structure of a LaTeX document.}
begin{minted}[linenos,bgcolor=orange!05]{latex}
documentclass{article}
begin{document}
end{document}
end{minted}
end{fancycode}
begin{fancycode}
stdcaption[Preamble]{The LaTeX preamble to do a texttt{fancycode}.}
begin{minted}[linenos,bgcolor=cyan!10]{latex}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
end{minted}
end{fancycode}
lipsum[1-2]
listof{fancycode}{Code examples}
end{document}
add a comment |
This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like
fboxdoes (with top caption inside usingstdcaption, for a botom caption outside the box usecaption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

documentclass[a6paper]{article}
usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
pagestyle{empty}
usepackage{lipsum}
letstdcaptioncaption
setcounter{totalnumber}{1}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
begin{document}
begin{fancycode}
stdcaption[Basic Structure]{The basic structure of a LaTeX document.}
begin{minted}[linenos,bgcolor=orange!05]{latex}
documentclass{article}
begin{document}
end{document}
end{minted}
end{fancycode}
begin{fancycode}
stdcaption[Preamble]{The LaTeX preamble to do a texttt{fancycode}.}
begin{minted}[linenos,bgcolor=cyan!10]{latex}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
end{minted}
end{fancycode}
lipsum[1-2]
listof{fancycode}{Code examples}
end{document}
This approach is not a simple environment but a standard minted environment nested in you own float environment. Not exactly the asked but:
☑ Each line in a src code block is numbered (optionally)
☑ The font used for a src code block is monospaced (and syntax highlited)
☑ A border is drawn around a code code block, much like
fboxdoes (with top caption inside usingstdcaption, for a botom caption outside the box usecaption*)
☑ Each code block "floats" to a position (concretely to top of a new page) so that it will fit all on one page.

documentclass[a6paper]{article}
usepackage[margin=1cm, paperheight=5in,paperwidth=5in]{geometry}
pagestyle{empty}
usepackage{lipsum}
letstdcaptioncaption
setcounter{totalnumber}{1}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
begin{document}
begin{fancycode}
stdcaption[Basic Structure]{The basic structure of a LaTeX document.}
begin{minted}[linenos,bgcolor=orange!05]{latex}
documentclass{article}
begin{document}
end{document}
end{minted}
end{fancycode}
begin{fancycode}
stdcaption[Preamble]{The LaTeX preamble to do a texttt{fancycode}.}
begin{minted}[linenos,bgcolor=cyan!10]{latex}
usepackage{minted}
usepackage{float}
floatstyle{boxed}
newfloat{fancycode}{t}{loa}
floatname{fancycode}{LaTeX code}
end{minted}
end{fancycode}
lipsum[1-2]
listof{fancycode}{Code examples}
end{document}
answered 2 hours ago
FranFran
51.6k6113175
51.6k6113175
add a comment |
add a comment |
IdleCustard is a new contributor. Be nice, and check out our Code of Conduct.
IdleCustard is a new contributor. Be nice, and check out our Code of Conduct.
IdleCustard is a new contributor. Be nice, and check out our Code of Conduct.
IdleCustard is a new contributor. Be nice, and check out our Code of Conduct.
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f469041%2fhow-can-we-define-our-own-simple-environment-for-source-code%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
What will
srcblockcontain in terms of characters?verbatim-like content, perhaps (symbols like#,_,$,^, ...)?– Werner
3 hours ago
Did you already check the
listingspackage? This should be straight-forward with it. Just read the manual.– Martin Scharrer♦
3 hours ago