How to adjust tikz picture so it fits to current size of a table cell?TikZ Picture in TableTikz Inside Table CellHow to make tikz center the cells of a matrix?Rotate a node but not its content: the case of the ellipse decorationHow do I prevent cellcolor from over effect of hlineHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionLine up nested tikz enviroments or how to get rid of themtorn paper problem compileThe right way to use tikz in a table?
Introducing Gladys, an intrepid globetrotter
Can you Ready a Bard spell to release it after using Battle Magic?
Something that can be activated/enabled
Find the cheapest shipping option based on item weight
How to increase the size of the cursor in Lubuntu 19.04?
Where are the "shires" in the UK?
Floor of Riemann zeta function
Can my company stop me from working overtime?
Word for Food that's Gone 'Bad', but is Still Edible?
Should I mention being denied entry to UK due to a confusion in my Visa and Ticket bookings?
Does the 7th major scale note resolve more strongly to the lower tonic (note 1) than the higher tonic (note 8)?
Copy previous line to current line from text file
Will 700 more planes a day fly because of the Heathrow expansion?
What to use instead of cling film to wrap pastry
How did the Venus Express detect lightning?
Where is the documentation for this ex command?
Nominativ or Akkusativ
How should I tell my manager I'm not paying for an optional after work event I'm not going to?
A factorization game
What if the end-user didn't have the required library?
Did we get closer to another plane than we were supposed to, or was the pilot just protecting our delicate sensibilities?
Out of scope work duties and resignation
What does 'made on' mean here?
Upside-Down Pyramid Addition...REVERSED!
How to adjust tikz picture so it fits to current size of a table cell?
TikZ Picture in TableTikz Inside Table CellHow to make tikz center the cells of a matrix?Rotate a node but not its content: the case of the ellipse decorationHow do I prevent cellcolor from over effect of hlineHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionLine up nested tikz enviroments or how to get rid of themtorn paper problem compileThe right way to use tikz in a table?
I already tried solutions given in 2 similar questions: TikZ Picture in Table and Tikz Inside Table Cell but they do not seem to work for me.
Below I give MWE and what I tried. I have a tikz picture inside a long table cell. I want it to automatically fit into the width of the cell.
When using an actual image and includegraphics
I would adjust the width
manually to make it fit. But do not know how to do it for a tikz pic.
I am also using the "m" option for the cell, to make the image align OK with text in other cells. But if I remove the "m" option and put back the "p" option on that cell, it makes no difference for the tikz scaling.
MWE
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center)]
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (4,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
How to scale the tikz pic size to automatically fit into a table cell?
Compiled using lualatex foo2.tex
using Using TL 2019 on linux.
lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
tikz-pgf tables
|
show 1 more comment
I already tried solutions given in 2 similar questions: TikZ Picture in Table and Tikz Inside Table Cell but they do not seem to work for me.
Below I give MWE and what I tried. I have a tikz picture inside a long table cell. I want it to automatically fit into the width of the cell.
When using an actual image and includegraphics
I would adjust the width
manually to make it fit. But do not know how to do it for a tikz pic.
I am also using the "m" option for the cell, to make the image align OK with text in other cells. But if I remove the "m" option and put back the "p" option on that cell, it makes no difference for the tikz scaling.
MWE
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center)]
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (4,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
How to scale the tikz pic size to automatically fit into a table cell?
Compiled using lualatex foo2.tex
using Using TL 2019 on linux.
lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
tikz-pgf tables
If you usecoordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.
– marmot
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When usingincludegraphics
I will set thewidth
to that of the cell width, whatever it is. (in this case, it is1.4in
) but this could change. Is there similar option in tikz?
– Nasser
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
Scaling fonts is OK. That what happens when changing width usingincludegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.
– Nasser
1 hour ago
Then you could loadadjustbox
and wrap yourtikzpicture
intoadjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.
– marmot
1 hour ago
|
show 1 more comment
I already tried solutions given in 2 similar questions: TikZ Picture in Table and Tikz Inside Table Cell but they do not seem to work for me.
Below I give MWE and what I tried. I have a tikz picture inside a long table cell. I want it to automatically fit into the width of the cell.
When using an actual image and includegraphics
I would adjust the width
manually to make it fit. But do not know how to do it for a tikz pic.
I am also using the "m" option for the cell, to make the image align OK with text in other cells. But if I remove the "m" option and put back the "p" option on that cell, it makes no difference for the tikz scaling.
MWE
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center)]
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (4,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
How to scale the tikz pic size to automatically fit into a table cell?
Compiled using lualatex foo2.tex
using Using TL 2019 on linux.
lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
tikz-pgf tables
I already tried solutions given in 2 similar questions: TikZ Picture in Table and Tikz Inside Table Cell but they do not seem to work for me.
Below I give MWE and what I tried. I have a tikz picture inside a long table cell. I want it to automatically fit into the width of the cell.
When using an actual image and includegraphics
I would adjust the width
manually to make it fit. But do not know how to do it for a tikz pic.
I am also using the "m" option for the cell, to make the image align OK with text in other cells. But if I remove the "m" option and put back the "p" option on that cell, it makes no difference for the tikz scaling.
MWE
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center)]
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (4,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
How to scale the tikz pic size to automatically fit into a table cell?
Compiled using lualatex foo2.tex
using Using TL 2019 on linux.
lualatex foo2.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
tikz-pgf tables
tikz-pgf tables
asked 1 hour ago
NasserNasser
8,37273290
8,37273290
If you usecoordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.
– marmot
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When usingincludegraphics
I will set thewidth
to that of the cell width, whatever it is. (in this case, it is1.4in
) but this could change. Is there similar option in tikz?
– Nasser
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
Scaling fonts is OK. That what happens when changing width usingincludegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.
– Nasser
1 hour ago
Then you could loadadjustbox
and wrap yourtikzpicture
intoadjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.
– marmot
1 hour ago
|
show 1 more comment
If you usecoordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.
– marmot
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When usingincludegraphics
I will set thewidth
to that of the cell width, whatever it is. (in this case, it is1.4in
) but this could change. Is there similar option in tikz?
– Nasser
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
Scaling fonts is OK. That what happens when changing width usingincludegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.
– Nasser
1 hour ago
Then you could loadadjustbox
and wrap yourtikzpicture
intoadjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.
– marmot
1 hour ago
If you use
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.– marmot
1 hour ago
If you use
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.– marmot
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When using
includegraphics
I will set the width
to that of the cell width, whatever it is. (in this case, it is 1.4in
) but this could change. Is there similar option in tikz?– Nasser
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When using
includegraphics
I will set the width
to that of the cell width, whatever it is. (in this case, it is 1.4in
) but this could change. Is there similar option in tikz?– Nasser
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
Scaling fonts is OK. That what happens when changing width using
includegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.– Nasser
1 hour ago
Scaling fonts is OK. That what happens when changing width using
includegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.– Nasser
1 hour ago
Then you could load
adjustbox
and wrap your tikzpicture
into adjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.– marmot
1 hour ago
Then you could load
adjustbox
and wrap your tikzpicture
into adjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.– marmot
1 hour ago
|
show 1 more comment
2 Answers
2
active
oldest
votes
I guess that this must be some sort of a duplicate answer but anyway adjustbox
is made for such things. Note that if you do that, you should not use remember picture
and try to access the coordinates from "outside". And adjustbox
comes with its own mechanisms of vertical or horizontal alignment, but not using any seems to work fine. In any case, you should not expect baseline=(current bounding box.center)
to work properly here either. In a way, the tikzpicture
will behave as a graphics included with includegraphics
, but if that's what you want then adjustbox
seems to be the right tool.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
adjustboxmax width=1.2inbegintikzpicture
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
Addendum: as mentioned above you can rewrite the tikzpicture
in such a way that it has the desired width. However, this is not a general solution. I am adding this merely to say that there is no need to introduce ad hoc distances like 0.6linewidth
, but you do have to look at the picture and find out which are the left-most and right-most nodes (u=0
and u_x=0
in this case). One can then start with those "extremal nodes", use appropriate anchors (along with outer sep=0pt
) to place them such that the picture has the right width, and then add the rest relative to them.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center),nodes=outer xsep=0pt]
node[anchor=west] (A0) at (0,0) $u=0$;
node[anchor=east] (B0) at (linewidth,0) $u_x=0$;
node[label=above:$0$] (A) at ([yshift=0.2ex]A0.north) [circle,fill,inner sep=1pt];
node[label =above:$pi$] (B) at (B0|-A) [circle,fill,inner sep=1pt];
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
add a comment |
make image width(determined with line length + width of nodes) dependent from cell width:
documentclass[11pt]article
usepackagegeometry
usepackagemathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit,
positioning,
quotes
usepackagearray, longtable
%---------------- show page layout. don't use in a real document!
usepackageshowframe
renewcommandShowFrameLinethickness0.15pt
renewcommand*ShowFrameColorcolorred
begindocument
begingroup
beginlongtablehline
A & Heat PDE in bar (1D)
& begintikzpicture[baseline=(current bounding box.base),
every node/.append style = font=footnotesize,
dot/.style = circle, fill, inner sep=2pt
]
node (A) [dot,label=$0$, label=below:$u=0$] ;
node (B) [dot,label=$pi$, label=below:$u_x=0$,
right=0.6linewidth of A] ; % <---
draw (A) to ["$u_t=k u_xx$","$f(x)$" '](B);
endtikzpicture
(Haberman 2.3.3 (a))
& B & 0.415 & C & 2.376 & Yes \
hline
endlongtable
endgroup
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%2f488857%2fhow-to-adjust-tikz-picture-so-it-fits-to-current-size-of-a-table-cell%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
I guess that this must be some sort of a duplicate answer but anyway adjustbox
is made for such things. Note that if you do that, you should not use remember picture
and try to access the coordinates from "outside". And adjustbox
comes with its own mechanisms of vertical or horizontal alignment, but not using any seems to work fine. In any case, you should not expect baseline=(current bounding box.center)
to work properly here either. In a way, the tikzpicture
will behave as a graphics included with includegraphics
, but if that's what you want then adjustbox
seems to be the right tool.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
adjustboxmax width=1.2inbegintikzpicture
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
Addendum: as mentioned above you can rewrite the tikzpicture
in such a way that it has the desired width. However, this is not a general solution. I am adding this merely to say that there is no need to introduce ad hoc distances like 0.6linewidth
, but you do have to look at the picture and find out which are the left-most and right-most nodes (u=0
and u_x=0
in this case). One can then start with those "extremal nodes", use appropriate anchors (along with outer sep=0pt
) to place them such that the picture has the right width, and then add the rest relative to them.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center),nodes=outer xsep=0pt]
node[anchor=west] (A0) at (0,0) $u=0$;
node[anchor=east] (B0) at (linewidth,0) $u_x=0$;
node[label=above:$0$] (A) at ([yshift=0.2ex]A0.north) [circle,fill,inner sep=1pt];
node[label =above:$pi$] (B) at (B0|-A) [circle,fill,inner sep=1pt];
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
add a comment |
I guess that this must be some sort of a duplicate answer but anyway adjustbox
is made for such things. Note that if you do that, you should not use remember picture
and try to access the coordinates from "outside". And adjustbox
comes with its own mechanisms of vertical or horizontal alignment, but not using any seems to work fine. In any case, you should not expect baseline=(current bounding box.center)
to work properly here either. In a way, the tikzpicture
will behave as a graphics included with includegraphics
, but if that's what you want then adjustbox
seems to be the right tool.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
adjustboxmax width=1.2inbegintikzpicture
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
Addendum: as mentioned above you can rewrite the tikzpicture
in such a way that it has the desired width. However, this is not a general solution. I am adding this merely to say that there is no need to introduce ad hoc distances like 0.6linewidth
, but you do have to look at the picture and find out which are the left-most and right-most nodes (u=0
and u_x=0
in this case). One can then start with those "extremal nodes", use appropriate anchors (along with outer sep=0pt
) to place them such that the picture has the right width, and then add the rest relative to them.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center),nodes=outer xsep=0pt]
node[anchor=west] (A0) at (0,0) $u=0$;
node[anchor=east] (B0) at (linewidth,0) $u_x=0$;
node[label=above:$0$] (A) at ([yshift=0.2ex]A0.north) [circle,fill,inner sep=1pt];
node[label =above:$pi$] (B) at (B0|-A) [circle,fill,inner sep=1pt];
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
add a comment |
I guess that this must be some sort of a duplicate answer but anyway adjustbox
is made for such things. Note that if you do that, you should not use remember picture
and try to access the coordinates from "outside". And adjustbox
comes with its own mechanisms of vertical or horizontal alignment, but not using any seems to work fine. In any case, you should not expect baseline=(current bounding box.center)
to work properly here either. In a way, the tikzpicture
will behave as a graphics included with includegraphics
, but if that's what you want then adjustbox
seems to be the right tool.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
adjustboxmax width=1.2inbegintikzpicture
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
Addendum: as mentioned above you can rewrite the tikzpicture
in such a way that it has the desired width. However, this is not a general solution. I am adding this merely to say that there is no need to introduce ad hoc distances like 0.6linewidth
, but you do have to look at the picture and find out which are the left-most and right-most nodes (u=0
and u_x=0
in this case). One can then start with those "extremal nodes", use appropriate anchors (along with outer sep=0pt
) to place them such that the picture has the right width, and then add the rest relative to them.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center),nodes=outer xsep=0pt]
node[anchor=west] (A0) at (0,0) $u=0$;
node[anchor=east] (B0) at (linewidth,0) $u_x=0$;
node[label=above:$0$] (A) at ([yshift=0.2ex]A0.north) [circle,fill,inner sep=1pt];
node[label =above:$pi$] (B) at (B0|-A) [circle,fill,inner sep=1pt];
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
I guess that this must be some sort of a duplicate answer but anyway adjustbox
is made for such things. Note that if you do that, you should not use remember picture
and try to access the coordinates from "outside". And adjustbox
comes with its own mechanisms of vertical or horizontal alignment, but not using any seems to work fine. In any case, you should not expect baseline=(current bounding box.center)
to work properly here either. In a way, the tikzpicture
will behave as a graphics included with includegraphics
, but if that's what you want then adjustbox
seems to be the right tool.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
adjustboxmax width=1.2inbegintikzpicture
coordinate[label =above:$0$, label =below:$u=0$] (A) at (0,0);
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
node at (A)[circle,fill,inner sep=1pt];
node at (B)[circle,fill,inner sep=1pt];
%addvmargin1mm %has no effect if I uncomment it
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
Addendum: as mentioned above you can rewrite the tikzpicture
in such a way that it has the desired width. However, this is not a general solution. I am adding this merely to say that there is no need to introduce ad hoc distances like 0.6linewidth
, but you do have to look at the picture and find out which are the left-most and right-most nodes (u=0
and u_x=0
in this case). One can then start with those "extremal nodes", use appropriate anchors (along with outer sep=0pt
) to place them such that the picture has the right width, and then add the rest relative to them.
documentclass[11pt]article
usepackageamsmath,mathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,tikz-dependency
usetikzlibraryfit
usepackagelongtable
usepackagearray %for the m option on cells
usepackageadjustbox
begindocument
beginlongtable[c]p0.5inhline
A&
Heat PDE in bar (1D)&
begintikzpicture[baseline=(current bounding box.center),nodes=outer xsep=0pt]
node[anchor=west] (A0) at (0,0) $u=0$;
node[anchor=east] (B0) at (linewidth,0) $u_x=0$;
node[label=above:$0$] (A) at ([yshift=0.2ex]A0.north) [circle,fill,inner sep=1pt];
node[label =above:$pi$] (B) at (B0|-A) [circle,fill,inner sep=1pt];
draw (A) -- node[above] $u_t = k u_xx $ node[below] $f(x)$ ++ (B);
endtikzpicture
(Haberman 2.3.3 (a))&
B&0.415&C&2.376&Yes\hline
endlongtable
enddocument
edited 22 mins ago
answered 1 hour ago
marmotmarmot
123k6160301
123k6160301
add a comment |
add a comment |
make image width(determined with line length + width of nodes) dependent from cell width:
documentclass[11pt]article
usepackagegeometry
usepackagemathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit,
positioning,
quotes
usepackagearray, longtable
%---------------- show page layout. don't use in a real document!
usepackageshowframe
renewcommandShowFrameLinethickness0.15pt
renewcommand*ShowFrameColorcolorred
begindocument
begingroup
beginlongtablehline
A & Heat PDE in bar (1D)
& begintikzpicture[baseline=(current bounding box.base),
every node/.append style = font=footnotesize,
dot/.style = circle, fill, inner sep=2pt
]
node (A) [dot,label=$0$, label=below:$u=0$] ;
node (B) [dot,label=$pi$, label=below:$u_x=0$,
right=0.6linewidth of A] ; % <---
draw (A) to ["$u_t=k u_xx$","$f(x)$" '](B);
endtikzpicture
(Haberman 2.3.3 (a))
& B & 0.415 & C & 2.376 & Yes \
hline
endlongtable
endgroup
enddocument
add a comment |
make image width(determined with line length + width of nodes) dependent from cell width:
documentclass[11pt]article
usepackagegeometry
usepackagemathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit,
positioning,
quotes
usepackagearray, longtable
%---------------- show page layout. don't use in a real document!
usepackageshowframe
renewcommandShowFrameLinethickness0.15pt
renewcommand*ShowFrameColorcolorred
begindocument
begingroup
beginlongtablehline
A & Heat PDE in bar (1D)
& begintikzpicture[baseline=(current bounding box.base),
every node/.append style = font=footnotesize,
dot/.style = circle, fill, inner sep=2pt
]
node (A) [dot,label=$0$, label=below:$u=0$] ;
node (B) [dot,label=$pi$, label=below:$u_x=0$,
right=0.6linewidth of A] ; % <---
draw (A) to ["$u_t=k u_xx$","$f(x)$" '](B);
endtikzpicture
(Haberman 2.3.3 (a))
& B & 0.415 & C & 2.376 & Yes \
hline
endlongtable
endgroup
enddocument
add a comment |
make image width(determined with line length + width of nodes) dependent from cell width:
documentclass[11pt]article
usepackagegeometry
usepackagemathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit,
positioning,
quotes
usepackagearray, longtable
%---------------- show page layout. don't use in a real document!
usepackageshowframe
renewcommandShowFrameLinethickness0.15pt
renewcommand*ShowFrameColorcolorred
begindocument
begingroup
beginlongtablehline
A & Heat PDE in bar (1D)
& begintikzpicture[baseline=(current bounding box.base),
every node/.append style = font=footnotesize,
dot/.style = circle, fill, inner sep=2pt
]
node (A) [dot,label=$0$, label=below:$u=0$] ;
node (B) [dot,label=$pi$, label=below:$u_x=0$,
right=0.6linewidth of A] ; % <---
draw (A) to ["$u_t=k u_xx$","$f(x)$" '](B);
endtikzpicture
(Haberman 2.3.3 (a))
& B & 0.415 & C & 2.376 & Yes \
hline
endlongtable
endgroup
enddocument
make image width(determined with line length + width of nodes) dependent from cell width:
documentclass[11pt]article
usepackagegeometry
usepackagemathtools,amssymb
ifdefinedHCode %Michal's driver for tex4ht use
defpgfsysdriverpgfsys-dvisvgm4ht.def
fi
usepackagetikz,graphicx,tikz-dependency
usetikzlibraryfit,
positioning,
quotes
usepackagearray, longtable
%---------------- show page layout. don't use in a real document!
usepackageshowframe
renewcommandShowFrameLinethickness0.15pt
renewcommand*ShowFrameColorcolorred
begindocument
begingroup
beginlongtablehline
A & Heat PDE in bar (1D)
& begintikzpicture[baseline=(current bounding box.base),
every node/.append style = font=footnotesize,
dot/.style = circle, fill, inner sep=2pt
]
node (A) [dot,label=$0$, label=below:$u=0$] ;
node (B) [dot,label=$pi$, label=below:$u_x=0$,
right=0.6linewidth of A] ; % <---
draw (A) to ["$u_t=k u_xx$","$f(x)$" '](B);
endtikzpicture
(Haberman 2.3.3 (a))
& B & 0.415 & C & 2.376 & Yes \
hline
endlongtable
endgroup
enddocument
edited 21 mins ago
answered 48 mins ago
ZarkoZarko
132k871171
132k871171
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%2f488857%2fhow-to-adjust-tikz-picture-so-it-fits-to-current-size-of-a-table-cell%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
If you use
coordinate[label =above:$pi$, label =below:$u_x=0$] (B) at (0.95in,0);
it almost fits.– marmot
1 hour ago
@marmot thanks. But this is just one example. I plan to draw many such small diagrams and each will be little different, and I do not want to do manual adjustments to each one image code. When using
includegraphics
I will set thewidth
to that of the cell width, whatever it is. (in this case, it is1.4in
) but this could change. Is there similar option in tikz?– Nasser
1 hour ago
There is adjustbox but the issue is that it rescales the fonts, too. One can rewrite your tikzpicture rather easily in such a way that it is 1.2in wide, but this is not a general solution.
– marmot
1 hour ago
Scaling fonts is OK. That what happens when changing width using
includegraphics
I basically want everything in the tikz to scale so it fits. It is ok if it get small to read.– Nasser
1 hour ago
Then you could load
adjustbox
and wrap yourtikzpicture
intoadjustboxmax width=1.2in ...
. This works fine as long as you do not want to remember the coordinates and use them elsewhere.– marmot
1 hour ago