How do I remove extra padding from drawing on a figure with tikz?How to add a scalebar to an imageRotate a...
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
Why publish a research paper when a blog post or a lecture slide can have more citation count than a journal paper?
Play Zip, Zap, Zop
How to play electric guitar and bass as a duet
Making him into a bully (how to show mild violence)
Why don't hotels mount air conditioning units outside the rooms?
Words and Words with "ver-" Prefix
Why was Lupin comfortable with saying Voldemort's name?
Absorbing damage with Planeswalker
Difference between i++ and (i)++ in C
Odd 74HCT1G125 behaviour
Why is Agricola named as such?
How to tell if a BJT is PNP or NPN by looking at the circuit?
using 'echo' & 'printf' in bash function calls
Why do neural networks need so many training examples to perform?
How to make ice magic work from a scientific point of view?
Exchange Online Migration: Single Tenant with Multiple Exchange Endpoints
How to deal with an incendiary email that was recalled
Gear reduction on large turbofans
Aligning symbols underneath each other neatly
Am I a Rude Number?
In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?
How do you funnel food off a cutting board?
How can I play a serial killer in a party of good PCs?
How do I remove extra padding from drawing on a figure with tikz?
How to add a scalebar to an imageRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?Drawing arrows from one side of a rectangle to other nodes without suitable anchorsTikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?Help understanding the coordinate system used in tikzLine up nested tikz enviroments or how to get rid of themKeep Figures RIGHT AFTER textUsing tikz Calc package to add cordinatesTIKZ Matrix nodes filled with colour afterwards and set to background
I am trying to draw over a figure using tikz, using a method for adding scalebars from this answer. The figures that are drawn over this way have extra padding around them that I can't get rid of. Compare the top row of the image below with the bottom row.
I can kind of workaround it by adding an hskip and manually finding the right number for a give figure (see commented out portion of MWE)

documentclass[12pt,a4paper]{article}
usepackage{graphicx}
usepackage{subcaption}
usepackage{tikz}
% Add a scalebar to an image
newcommand{scalebar}[5][white]{%
noindentbegin{tikzpicture}
draw (0,0) node[anchor=south west,inner sep=0] (image) { #2 };
begin{scope}[x={(image.south east)},y={(image.north west)}]
fill [fill=black, fill opacity=0.5] (0.02,0.1cm) rectangle (#4/#3+0.12,1cm);
fill [#1] (0.05,0.2cm) rectangle (#4/#3+0.05,0.4cm);
draw [#1] (0.00,0.4cm) node[anchor=south west, font=footnotesize] {{#4}{#5} };
end{scope}
end{tikzpicture} %hskip -1pt % This is my only workaround
}
begin{document}
begin{figure}[h]
centering
begin{subfigure}{textwidth}
caption{}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
begin{subfigure}{textwidth}
caption{}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
end{figure}
end{document}
tikz-pgf floats subcaption
add a comment |
I am trying to draw over a figure using tikz, using a method for adding scalebars from this answer. The figures that are drawn over this way have extra padding around them that I can't get rid of. Compare the top row of the image below with the bottom row.
I can kind of workaround it by adding an hskip and manually finding the right number for a give figure (see commented out portion of MWE)

documentclass[12pt,a4paper]{article}
usepackage{graphicx}
usepackage{subcaption}
usepackage{tikz}
% Add a scalebar to an image
newcommand{scalebar}[5][white]{%
noindentbegin{tikzpicture}
draw (0,0) node[anchor=south west,inner sep=0] (image) { #2 };
begin{scope}[x={(image.south east)},y={(image.north west)}]
fill [fill=black, fill opacity=0.5] (0.02,0.1cm) rectangle (#4/#3+0.12,1cm);
fill [#1] (0.05,0.2cm) rectangle (#4/#3+0.05,0.4cm);
draw [#1] (0.00,0.4cm) node[anchor=south west, font=footnotesize] {{#4}{#5} };
end{scope}
end{tikzpicture} %hskip -1pt % This is my only workaround
}
begin{document}
begin{figure}[h]
centering
begin{subfigure}{textwidth}
caption{}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
begin{subfigure}{textwidth}
caption{}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
end{figure}
end{document}
tikz-pgf floats subcaption
What happens if you setouter sep=0?
– marmot
6 secs ago
add a comment |
I am trying to draw over a figure using tikz, using a method for adding scalebars from this answer. The figures that are drawn over this way have extra padding around them that I can't get rid of. Compare the top row of the image below with the bottom row.
I can kind of workaround it by adding an hskip and manually finding the right number for a give figure (see commented out portion of MWE)

documentclass[12pt,a4paper]{article}
usepackage{graphicx}
usepackage{subcaption}
usepackage{tikz}
% Add a scalebar to an image
newcommand{scalebar}[5][white]{%
noindentbegin{tikzpicture}
draw (0,0) node[anchor=south west,inner sep=0] (image) { #2 };
begin{scope}[x={(image.south east)},y={(image.north west)}]
fill [fill=black, fill opacity=0.5] (0.02,0.1cm) rectangle (#4/#3+0.12,1cm);
fill [#1] (0.05,0.2cm) rectangle (#4/#3+0.05,0.4cm);
draw [#1] (0.00,0.4cm) node[anchor=south west, font=footnotesize] {{#4}{#5} };
end{scope}
end{tikzpicture} %hskip -1pt % This is my only workaround
}
begin{document}
begin{figure}[h]
centering
begin{subfigure}{textwidth}
caption{}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
begin{subfigure}{textwidth}
caption{}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
end{figure}
end{document}
tikz-pgf floats subcaption
I am trying to draw over a figure using tikz, using a method for adding scalebars from this answer. The figures that are drawn over this way have extra padding around them that I can't get rid of. Compare the top row of the image below with the bottom row.
I can kind of workaround it by adding an hskip and manually finding the right number for a give figure (see commented out portion of MWE)

documentclass[12pt,a4paper]{article}
usepackage{graphicx}
usepackage{subcaption}
usepackage{tikz}
% Add a scalebar to an image
newcommand{scalebar}[5][white]{%
noindentbegin{tikzpicture}
draw (0,0) node[anchor=south west,inner sep=0] (image) { #2 };
begin{scope}[x={(image.south east)},y={(image.north west)}]
fill [fill=black, fill opacity=0.5] (0.02,0.1cm) rectangle (#4/#3+0.12,1cm);
fill [#1] (0.05,0.2cm) rectangle (#4/#3+0.05,0.4cm);
draw [#1] (0.00,0.4cm) node[anchor=south west, font=footnotesize] {{#4}{#5} };
end{scope}
end{tikzpicture} %hskip -1pt % This is my only workaround
}
begin{document}
begin{figure}[h]
centering
begin{subfigure}{textwidth}
caption{}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
begin{subfigure}{textwidth}
caption{}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
scalebar{includegraphics[width=.3textwidth]{example-image-golden}}{6}{1}{mm}
includegraphics[width=.3textwidth]{example-image-golden}
end{subfigure}
end{figure}
end{document}
tikz-pgf floats subcaption
tikz-pgf floats subcaption
asked 3 mins ago
argentum2fargentum2f
1063
1063
What happens if you setouter sep=0?
– marmot
6 secs ago
add a comment |
What happens if you setouter sep=0?
– marmot
6 secs ago
What happens if you set
outer sep=0?– marmot
6 secs ago
What happens if you set
outer sep=0?– marmot
6 secs ago
add a comment |
0
active
oldest
votes
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%2f477054%2fhow-do-i-remove-extra-padding-from-drawing-on-a-figure-with-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f477054%2fhow-do-i-remove-extra-padding-from-drawing-on-a-figure-with-tikz%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 happens if you set
outer sep=0?– marmot
6 secs ago