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?

ZSPL language, anyone heard of it?

In Stroustrup's example, what does this colon mean in `return 1 : 2`? It's not a label or ternary operator

What was the first story to feature the plot "the monsters were human all along"?

What are the advantages of luxury car brands like Acura/Lexus over their sibling non-luxury brands Honda/Toyota?

How can internet speed be 10 times slower without a router than when using a router?

Causes of bimodal distributions when bootstrapping a meta-analysis model

What is the solution to this metapuzzle from a university puzzling column?

PWM 1Hz on solid state relay

Should homeowners insurance cover the cost of the home?

Floor of Riemann zeta function

Would glacier 'trees' be plausible?

Adjacent DEM color matching in QGIS

Why does sound not move through a wall?

Find the cheapest shipping option based on item weight

How do inspiraling black holes get closer?

Shutter speed -vs- effective image stabilisation

What does "Managed by Windows" do in the Power options for network connection?

I need a disease

What are the differences between credential stuffing and password spraying?

Can I use a fetch land to shuffle my deck while the opponent has Ashiok, Dream Render in play?

Are the Night's Watch still required?

How can I get people to remember my character's gender?

In Russian, how do you idiomatically express the idea of the figurative "overnight"?

Introducing Gladys, an intrepid globetrotter



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?













1















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


Mathematica graphics



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.









share|improve this question






















  • 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












  • 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 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















1















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


Mathematica graphics



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.









share|improve this question






















  • 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












  • 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 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













1












1








1








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


Mathematica graphics



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.









share|improve this question














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


Mathematica graphics



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









NasserNasser

8,37273290




8,37273290












  • 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












  • 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 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

















  • 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












  • 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 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
















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










2 Answers
2






active

oldest

votes


















3














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


enter image description here



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


enter image description here






share|improve this answer
































    2














    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
    beginlongtablem0.25inhline
    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


    enter image description here






    share|improve this answer

























      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
      );



      );













      draft saved

      draft discarded


















      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









      3














      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


      enter image description here



      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


      enter image description here






      share|improve this answer





























        3














        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


        enter image description here



        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


        enter image description here






        share|improve this answer



























          3












          3








          3







          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


          enter image description here



          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


          enter image description here






          share|improve this answer















          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


          enter image description here



          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


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 18 mins ago

























          answered 1 hour ago









          marmotmarmot

          123k6160301




          123k6160301





















              2














              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
              beginlongtablem0.25inhline
              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


              enter image description here






              share|improve this answer





























                2














                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
                beginlongtablem0.25inhline
                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


                enter image description here






                share|improve this answer



























                  2












                  2








                  2







                  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
                  beginlongtablem0.25inhline
                  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


                  enter image description here






                  share|improve this answer















                  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
                  beginlongtablem0.25inhline
                  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


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 16 mins ago

























                  answered 44 mins ago









                  ZarkoZarko

                  132k871171




                  132k871171



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Log på Navigationsmenu

                      Creating second map without labels using QGIS?How to lock map labels for inset map in Print Composer?How to Force the Showing of Labels of a Vector File in QGISQGIS Valmiera, Labels only show for part of polygonsRemoving duplicate point labels in QGISLabeling every feature using QGIS?Show labels for point features outside map canvasAbbreviate Road Labels in QGIS only when requiredExporting map from composer in QGIS - text labels have moved in output?How to make sure labels in qgis turn up in layout map?Writing label expression with ArcMap and If then Statement?

                      Nuuk Indholdsfortegnelse Etyomologi | Historie | Geografi | Transport og infrastruktur | Politik og administration | Uddannelsesinstitutioner | Kultur | Venskabsbyer | Noter | Eksterne henvisninger | Se også | Navigationsmenuwww.sermersooq.gl64°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.75064°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.750DMI - KlimanormalerSalmonsen, s. 850Grønlands Naturinstitut undersøger rensdyr i Akia og Maniitsoq foråret 2008Grønlands NaturinstitutNy vej til Qinngorput indviet i dagAntallet af biler i Nuuk må begrænsesNy taxacentral mødt med demonstrationKøreplan. Rute 1, 2 og 3SnescootersporNuukNord er for storSkoler i Kommuneqarfik SermersooqAtuarfik Samuel KleinschmidtKangillinguit AtuarfiatNuussuup AtuarfiaNuuk Internationale FriskoleIlinniarfissuaq, Grønlands SeminariumLedelseÅrsberetning for 2008Kunst og arkitekturÅrsberetning for 2008Julie om naturenNuuk KunstmuseumSilamiutGrønlands Nationalmuseum og ArkivStatistisk ÅrbogGrønlands LandsbibliotekStore koncerter på stribeVandhund nummer 1.000.000Kommuneqarfik Sermersooq – MalikForsidenVenskabsbyerLyngby-Taarbæk i GrønlandArctic Business NetworkWinter Cities 2008 i NuukDagligt opdaterede satellitbilleder fra NuukområdetKommuneqarfik Sermersooqs hjemmesideTurist i NuukGrønlands Statistiks databankGrønlands Hjemmestyres valgresultaterrrWorldCat124325457671310-5