Insert a block of code as a paragraphInsert a block comment title in KileInsert Bash code with coloration...
Closed subgroups of abelian groups
Extreme, but not acceptable situation and I can't start the work tomorrow morning
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
What typically incentivizes a professor to change jobs to a lower ranking university?
When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?
My colleague's body is amazing
Schwarzchild Radius of the Universe
Can a German sentence have two subjects?
How is the relation "the smallest element is the same" reflexive?
What is the meaning of "of trouble" in the following sentence?
DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?
Can you lasso down a wizard who is using the Levitate spell?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Can town administrative "code" overule state laws like those forbidding trespassing?
Could a US political party gain complete control over the government by removing checks & balances?
Draw simple lines in Inkscape
How to use Pandas to get the count of every combination inclusive
Infinite past with a beginning?
Can I interfere when another PC is about to be attacked?
Is there a minimum number of transactions in a block?
Copenhagen passport control - US citizen
Motorized valve interfering with button?
The use of multiple foreign keys on same column in SQL Server
Insert a block of code as a paragraph
Insert a block comment title in KileInsert Bash code with coloration into my latex reportIs it possible to insert C++ code into LaTeX?How can I add a little code block instream with text?Fitting codes in a Latex Code blockinsert code keywords inlineHow to insert code from a Router or a SwitchInsert long Matlab code in beamer with scrolling windowUse `code` syntax to insert some codeHow to insert inline `code` in Lyx
Looking to display several lines of code in my report as one block, the same way that code is displayed on Stack Exchange. For inline code I've been using tikzhl
and texttt
:
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10] (X) {#1};}
This seems a good solution for code integrated in paragraphs:
But for several lines as their own paragraph it is not ideal:
What I would like to do is have it appear as the following with one bounding grey box:
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
Adding a new line where it is wider than the page margins if possible, although I can do this manually if not possible.
Thanks in advance. Using Texmaker with MiKTeX 2.9.
code
New contributor
add a comment |
Looking to display several lines of code in my report as one block, the same way that code is displayed on Stack Exchange. For inline code I've been using tikzhl
and texttt
:
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10] (X) {#1};}
This seems a good solution for code integrated in paragraphs:
But for several lines as their own paragraph it is not ideal:
What I would like to do is have it appear as the following with one bounding grey box:
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
Adding a new line where it is wider than the page margins if possible, although I can do this manually if not possible.
Thanks in advance. Using Texmaker with MiKTeX 2.9.
code
New contributor
1
You havelistings
andminted
specifically for this purpose. TikZ should not be used in this case.
– JouleV
13 hours ago
1
If you want to customize more that what these two packages can handle, you can usetcolorbox
withlistings
library.
– JouleV
13 hours ago
add a comment |
Looking to display several lines of code in my report as one block, the same way that code is displayed on Stack Exchange. For inline code I've been using tikzhl
and texttt
:
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10] (X) {#1};}
This seems a good solution for code integrated in paragraphs:
But for several lines as their own paragraph it is not ideal:
What I would like to do is have it appear as the following with one bounding grey box:
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
Adding a new line where it is wider than the page margins if possible, although I can do this manually if not possible.
Thanks in advance. Using Texmaker with MiKTeX 2.9.
code
New contributor
Looking to display several lines of code in my report as one block, the same way that code is displayed on Stack Exchange. For inline code I've been using tikzhl
and texttt
:
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10] (X) {#1};}
This seems a good solution for code integrated in paragraphs:
But for several lines as their own paragraph it is not ideal:
What I would like to do is have it appear as the following with one bounding grey box:
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
Adding a new line where it is wider than the page margins if possible, although I can do this manually if not possible.
Thanks in advance. Using Texmaker with MiKTeX 2.9.
code
code
New contributor
New contributor
edited 12 hours ago
JouleV
11.4k22561
11.4k22561
New contributor
asked 13 hours ago
JackJack
31
31
New contributor
New contributor
1
You havelistings
andminted
specifically for this purpose. TikZ should not be used in this case.
– JouleV
13 hours ago
1
If you want to customize more that what these two packages can handle, you can usetcolorbox
withlistings
library.
– JouleV
13 hours ago
add a comment |
1
You havelistings
andminted
specifically for this purpose. TikZ should not be used in this case.
– JouleV
13 hours ago
1
If you want to customize more that what these two packages can handle, you can usetcolorbox
withlistings
library.
– JouleV
13 hours ago
1
1
You have
listings
and minted
specifically for this purpose. TikZ should not be used in this case.– JouleV
13 hours ago
You have
listings
and minted
specifically for this purpose. TikZ should not be used in this case.– JouleV
13 hours ago
1
1
If you want to customize more that what these two packages can handle, you can use
tcolorbox
with listings
library.– JouleV
13 hours ago
If you want to customize more that what these two packages can handle, you can use
tcolorbox
with listings
library.– JouleV
13 hours ago
add a comment |
1 Answer
1
active
oldest
votes
I keep your tikzhl
command, but it won't work with something like tikzhl{documentclass}
(which is supposed to output documentclass
).
documentclass{article}
usepackage{listings}
usepackage{xcolor}
lstset{
basicstyle=ttfamily,
backgroundcolor=color{black!10},
breaklines=true
}
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10,font=ttfamily,inner sep=1pt] (X) {#1};}
begin{document}
begin{lstlisting}
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
end{lstlisting}
Package tikzhl{listings} can do it for you.
end{document}
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
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
});
}
});
Jack 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%2f483686%2finsert-a-block-of-code-as-a-paragraph%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
I keep your tikzhl
command, but it won't work with something like tikzhl{documentclass}
(which is supposed to output documentclass
).
documentclass{article}
usepackage{listings}
usepackage{xcolor}
lstset{
basicstyle=ttfamily,
backgroundcolor=color{black!10},
breaklines=true
}
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10,font=ttfamily,inner sep=1pt] (X) {#1};}
begin{document}
begin{lstlisting}
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
end{lstlisting}
Package tikzhl{listings} can do it for you.
end{document}
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
add a comment |
I keep your tikzhl
command, but it won't work with something like tikzhl{documentclass}
(which is supposed to output documentclass
).
documentclass{article}
usepackage{listings}
usepackage{xcolor}
lstset{
basicstyle=ttfamily,
backgroundcolor=color{black!10},
breaklines=true
}
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10,font=ttfamily,inner sep=1pt] (X) {#1};}
begin{document}
begin{lstlisting}
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
end{lstlisting}
Package tikzhl{listings} can do it for you.
end{document}
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
add a comment |
I keep your tikzhl
command, but it won't work with something like tikzhl{documentclass}
(which is supposed to output documentclass
).
documentclass{article}
usepackage{listings}
usepackage{xcolor}
lstset{
basicstyle=ttfamily,
backgroundcolor=color{black!10},
breaklines=true
}
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10,font=ttfamily,inner sep=1pt] (X) {#1};}
begin{document}
begin{lstlisting}
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
end{lstlisting}
Package tikzhl{listings} can do it for you.
end{document}
I keep your tikzhl
command, but it won't work with something like tikzhl{documentclass}
(which is supposed to output documentclass
).
documentclass{article}
usepackage{listings}
usepackage{xcolor}
lstset{
basicstyle=ttfamily,
backgroundcolor=color{black!10},
breaklines=true
}
usepackage{tikz}
newcommand*{tikzhl}[1]{tikz[baseline=(X.base)]
node[fill=black!10,font=ttfamily,inner sep=1pt] (X) {#1};}
begin{document}
begin{lstlisting}
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
end{lstlisting}
Package tikzhl{listings} can do it for you.
end{document}
answered 13 hours ago
JouleVJouleV
11.4k22561
11.4k22561
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
add a comment |
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
1
1
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
Perfect, thank you. This is just what I'm after!
– Jack
12 hours ago
add a comment |
Jack is a new contributor. Be nice, and check out our Code of Conduct.
Jack is a new contributor. Be nice, and check out our Code of Conduct.
Jack is a new contributor. Be nice, and check out our Code of Conduct.
Jack 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.
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%2f483686%2finsert-a-block-of-code-as-a-paragraph%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
You have
listings
andminted
specifically for this purpose. TikZ should not be used in this case.– JouleV
13 hours ago
1
If you want to customize more that what these two packages can handle, you can use
tcolorbox
withlistings
library.– JouleV
13 hours ago