Tikz - create rectangle with same width as the pictureRotate a node but not its content: the case of the ellipse decorationMake tikzpicture white on blackUML StatediagramHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?Problems with nested TikZpicturesTikZ diagram, placement of nodes, dotted lineHow to align node anchors on text?The TikZ pipeline: A path's 'draw' option has no effect on a 'behind path' nodeTIKZ Matrix nodes filled with colour afterwards and set to background

Which big number is bigger?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

How do I reattach a shelf to the wall when it ripped out of the wall?

As an international instructor, should I openly talk about my accent?

How can I practically buy stocks?

Does tea made with boiling water cool faster than tea made with boiled (but still hot) water?

555 timer FM transmitter

How to fry ground beef so it is well-browned

How did Captain America manage to do this?

Aligning equation numbers vertically

Betweenness centrality formula

How to prevent z-fighting in OpenSCAD?

Why does Mind Blank stop the Feeblemind spell?

Dynamic SOQL query relationship with field visibility for Users

How to pronounce 'c++' in Spanish

Are there physical dangers to preparing a prepared piano?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

Phrase for the opposite of "foolproof"

What is the philosophical significance of speech acts/implicature?

Can I criticise the more senior developers around me for not writing clean code?

Can someone publish a story that happened to you?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

Can an Area of Effect spell cast outside a Prismatic Wall extend inside it?



Tikz - create rectangle with same width as the picture


Rotate a node but not its content: the case of the ellipse decorationMake tikzpicture white on blackUML StatediagramHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?Problems with nested TikZpicturesTikZ diagram, placement of nodes, dotted lineHow to align node anchors on text?The TikZ pipeline: A path's 'draw' option has no effect on a 'behind path' nodeTIKZ Matrix nodes filled with colour afterwards and set to background













2















I have the following MWE:



documentclass[]standalone
usepackagetikz
usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
begindocument
begintikzpicture

% Headers
node (header1) large HeaderOne;
node[right=of header1] (header2) large HeaderTwo;

% Text
node[below=of header1.west, anchor=west] (text1) Short text;
node[below=of header2.west, anchor=west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

% Background
beginpgfonlayerbackground
node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east)] ;
endpgfonlayer

endtikzpicture
enddocument


which produces this: enter image description here



However, in addition, I would like to create a rectangle as background for HeaderOne and HeaderTwo, which also spans the width of the entire picture, a bit like this (please ignore the bad painting around the text itself; it should be drawn on the background layer):
enter image description here



I have tried using 'background top' from the pgf manual in conjunction with 'background rectangle', but this does not look good when you want to have drawn a black line (border) around everything as well (the border does not fit the entire picture then).



Thanks.










share|improve this question







New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Why don't you just use a table for that?

    – JouleV
    Apr 23 at 12:30






  • 1





    I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

    – PS.
    Apr 23 at 12:34











  • My suggestion is to make a table and place this table inside a node

    – JouleV
    Apr 23 at 12:35















2















I have the following MWE:



documentclass[]standalone
usepackagetikz
usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
begindocument
begintikzpicture

% Headers
node (header1) large HeaderOne;
node[right=of header1] (header2) large HeaderTwo;

% Text
node[below=of header1.west, anchor=west] (text1) Short text;
node[below=of header2.west, anchor=west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

% Background
beginpgfonlayerbackground
node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east)] ;
endpgfonlayer

endtikzpicture
enddocument


which produces this: enter image description here



However, in addition, I would like to create a rectangle as background for HeaderOne and HeaderTwo, which also spans the width of the entire picture, a bit like this (please ignore the bad painting around the text itself; it should be drawn on the background layer):
enter image description here



I have tried using 'background top' from the pgf manual in conjunction with 'background rectangle', but this does not look good when you want to have drawn a black line (border) around everything as well (the border does not fit the entire picture then).



Thanks.










share|improve this question







New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Why don't you just use a table for that?

    – JouleV
    Apr 23 at 12:30






  • 1





    I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

    – PS.
    Apr 23 at 12:34











  • My suggestion is to make a table and place this table inside a node

    – JouleV
    Apr 23 at 12:35













2












2








2








I have the following MWE:



documentclass[]standalone
usepackagetikz
usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
begindocument
begintikzpicture

% Headers
node (header1) large HeaderOne;
node[right=of header1] (header2) large HeaderTwo;

% Text
node[below=of header1.west, anchor=west] (text1) Short text;
node[below=of header2.west, anchor=west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

% Background
beginpgfonlayerbackground
node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east)] ;
endpgfonlayer

endtikzpicture
enddocument


which produces this: enter image description here



However, in addition, I would like to create a rectangle as background for HeaderOne and HeaderTwo, which also spans the width of the entire picture, a bit like this (please ignore the bad painting around the text itself; it should be drawn on the background layer):
enter image description here



I have tried using 'background top' from the pgf manual in conjunction with 'background rectangle', but this does not look good when you want to have drawn a black line (border) around everything as well (the border does not fit the entire picture then).



Thanks.










share|improve this question







New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have the following MWE:



documentclass[]standalone
usepackagetikz
usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
begindocument
begintikzpicture

% Headers
node (header1) large HeaderOne;
node[right=of header1] (header2) large HeaderTwo;

% Text
node[below=of header1.west, anchor=west] (text1) Short text;
node[below=of header2.west, anchor=west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

% Background
beginpgfonlayerbackground
node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east)] ;
endpgfonlayer

endtikzpicture
enddocument


which produces this: enter image description here



However, in addition, I would like to create a rectangle as background for HeaderOne and HeaderTwo, which also spans the width of the entire picture, a bit like this (please ignore the bad painting around the text itself; it should be drawn on the background layer):
enter image description here



I have tried using 'background top' from the pgf manual in conjunction with 'background rectangle', but this does not look good when you want to have drawn a black line (border) around everything as well (the border does not fit the entire picture then).



Thanks.







tikz-pgf backgrounds






share|improve this question







New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 23 at 12:22









PS.PS.

162




162




New contributor




PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






PS. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Why don't you just use a table for that?

    – JouleV
    Apr 23 at 12:30






  • 1





    I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

    – PS.
    Apr 23 at 12:34











  • My suggestion is to make a table and place this table inside a node

    – JouleV
    Apr 23 at 12:35

















  • Why don't you just use a table for that?

    – JouleV
    Apr 23 at 12:30






  • 1





    I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

    – PS.
    Apr 23 at 12:34











  • My suggestion is to make a table and place this table inside a node

    – JouleV
    Apr 23 at 12:35
















Why don't you just use a table for that?

– JouleV
Apr 23 at 12:30





Why don't you just use a table for that?

– JouleV
Apr 23 at 12:30




1




1





I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

– PS.
Apr 23 at 12:34





I have further elements in my actual tikz picture (i.e. code which is inherent to tikz, and would not fit into a table). Sorry I didnt mention that.

– PS.
Apr 23 at 12:34













My suggestion is to make a table and place this table inside a node

– JouleV
Apr 23 at 12:35





My suggestion is to make a table and place this table inside a node

– JouleV
Apr 23 at 12:35










2 Answers
2






active

oldest

votes


















4














Just add another fit node and do not forget inner sep=0pt.



documentclass[]standalone
usepackagetikz
usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
begindocument
begintikzpicture[every node/.style=minimum height=5ex]

% Headers
node (header1) large HeaderOne;
node[right=of header1] (header2) large HeaderTwo;

% Text
node[below=0pt of header1.south west, anchor=north west] (text1) Short text;
node[below=0pt of header2.south west, anchor=north west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

% Background
beginpgfonlayerbackground
node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east), inner sep=0pt] ;
node [fill=red, draw=black, fit=(header1)(header2)(current bounding box.north east), inner sep=0pt] ;
endpgfonlayer

endtikzpicture
enddocument


enter image description here






share|improve this answer

























  • @JouleV That depends on below of, I'll improve soon.

    – CarLaTeX
    Apr 23 at 12:58






  • 1





    @JouleV Yes, that's also a good solution, see my now.

    – CarLaTeX
    Apr 23 at 13:05











  • @CarLaTeX: Thanks for your solution - exactly what I needed.

    – PS.
    Apr 23 at 13:59











  • @PS. You're welcome! Thank you for accepting my answer!

    – CarLaTeX
    Apr 23 at 14:00


















4














Why don't use a simple table for that?



documentclass[margin=3]standalone
usepackagecolortbl
usepackagexcolor
begindocument
renewcommandarraystretch1.5
begintabularll
hline
rowcolorredlarge HeaderOne & large HeaderTwo\hline
rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
hline
endtabular
enddocument


enter image description here



If you want to use this table inside a TikZ picture, simply place it inside a node.



documentclass[margin=3,tikz]standalone
usepackagecolortbl
usepackagexcolor
begindocument
tikznoderenewcommandarraystretch1.5%
begintabularll
hline
rowcolorredlarge HeaderOne & large HeaderTwo\hline
rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
hline
endtabular;
enddocument


With pure TikZ it is also not that complicated. No need of PGF layers. However, I don't recommend this way.



documentclass[margin=3,tikz]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance=0pt,inner sep=7pt]
node[text width=3cm,font=largecolorwhite,fill=red] (header1) HeaderOne;
node[text width=3cm,below=of header1,fill=gray!20] (text1) Short text;
node[text width=13cm,font=largecolorwhite,fill=red,right=-pgflinewidth of header1] (header2) HeaderTwo;
node[text width=13cm,below=of header2,fill=gray!20] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;
draw (header1.north west) -- (header2.north east)
(header1.south west) -- (header2.south east)
(text1.south west) -- (text2.south east);
endtikzpicture
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
    );



    );






    PS. is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486187%2ftikz-create-rectangle-with-same-width-as-the-picture%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









    4














    Just add another fit node and do not forget inner sep=0pt.



    documentclass[]standalone
    usepackagetikz
    usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
    begindocument
    begintikzpicture[every node/.style=minimum height=5ex]

    % Headers
    node (header1) large HeaderOne;
    node[right=of header1] (header2) large HeaderTwo;

    % Text
    node[below=0pt of header1.south west, anchor=north west] (text1) Short text;
    node[below=0pt of header2.south west, anchor=north west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

    % Background
    beginpgfonlayerbackground
    node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east), inner sep=0pt] ;
    node [fill=red, draw=black, fit=(header1)(header2)(current bounding box.north east), inner sep=0pt] ;
    endpgfonlayer

    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • @JouleV That depends on below of, I'll improve soon.

      – CarLaTeX
      Apr 23 at 12:58






    • 1





      @JouleV Yes, that's also a good solution, see my now.

      – CarLaTeX
      Apr 23 at 13:05











    • @CarLaTeX: Thanks for your solution - exactly what I needed.

      – PS.
      Apr 23 at 13:59











    • @PS. You're welcome! Thank you for accepting my answer!

      – CarLaTeX
      Apr 23 at 14:00















    4














    Just add another fit node and do not forget inner sep=0pt.



    documentclass[]standalone
    usepackagetikz
    usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
    begindocument
    begintikzpicture[every node/.style=minimum height=5ex]

    % Headers
    node (header1) large HeaderOne;
    node[right=of header1] (header2) large HeaderTwo;

    % Text
    node[below=0pt of header1.south west, anchor=north west] (text1) Short text;
    node[below=0pt of header2.south west, anchor=north west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

    % Background
    beginpgfonlayerbackground
    node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east), inner sep=0pt] ;
    node [fill=red, draw=black, fit=(header1)(header2)(current bounding box.north east), inner sep=0pt] ;
    endpgfonlayer

    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • @JouleV That depends on below of, I'll improve soon.

      – CarLaTeX
      Apr 23 at 12:58






    • 1





      @JouleV Yes, that's also a good solution, see my now.

      – CarLaTeX
      Apr 23 at 13:05











    • @CarLaTeX: Thanks for your solution - exactly what I needed.

      – PS.
      Apr 23 at 13:59











    • @PS. You're welcome! Thank you for accepting my answer!

      – CarLaTeX
      Apr 23 at 14:00













    4












    4








    4







    Just add another fit node and do not forget inner sep=0pt.



    documentclass[]standalone
    usepackagetikz
    usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
    begindocument
    begintikzpicture[every node/.style=minimum height=5ex]

    % Headers
    node (header1) large HeaderOne;
    node[right=of header1] (header2) large HeaderTwo;

    % Text
    node[below=0pt of header1.south west, anchor=north west] (text1) Short text;
    node[below=0pt of header2.south west, anchor=north west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

    % Background
    beginpgfonlayerbackground
    node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east), inner sep=0pt] ;
    node [fill=red, draw=black, fit=(header1)(header2)(current bounding box.north east), inner sep=0pt] ;
    endpgfonlayer

    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer















    Just add another fit node and do not forget inner sep=0pt.



    documentclass[]standalone
    usepackagetikz
    usetikzlibrarypositioning,fit,shapes.geometric,calc,backgrounds
    begindocument
    begintikzpicture[every node/.style=minimum height=5ex]

    % Headers
    node (header1) large HeaderOne;
    node[right=of header1] (header2) large HeaderTwo;

    % Text
    node[below=0pt of header1.south west, anchor=north west] (text1) Short text;
    node[below=0pt of header2.south west, anchor=north west] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;

    % Background
    beginpgfonlayerbackground
    node [fill=gray!20, draw=black, fit=(current bounding box.north west) (current bounding box.south east), inner sep=0pt] ;
    node [fill=red, draw=black, fit=(header1)(header2)(current bounding box.north east), inner sep=0pt] ;
    endpgfonlayer

    endtikzpicture
    enddocument


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 23 at 13:04

























    answered Apr 23 at 12:53









    CarLaTeXCarLaTeX

    36k556153




    36k556153












    • @JouleV That depends on below of, I'll improve soon.

      – CarLaTeX
      Apr 23 at 12:58






    • 1





      @JouleV Yes, that's also a good solution, see my now.

      – CarLaTeX
      Apr 23 at 13:05











    • @CarLaTeX: Thanks for your solution - exactly what I needed.

      – PS.
      Apr 23 at 13:59











    • @PS. You're welcome! Thank you for accepting my answer!

      – CarLaTeX
      Apr 23 at 14:00

















    • @JouleV That depends on below of, I'll improve soon.

      – CarLaTeX
      Apr 23 at 12:58






    • 1





      @JouleV Yes, that's also a good solution, see my now.

      – CarLaTeX
      Apr 23 at 13:05











    • @CarLaTeX: Thanks for your solution - exactly what I needed.

      – PS.
      Apr 23 at 13:59











    • @PS. You're welcome! Thank you for accepting my answer!

      – CarLaTeX
      Apr 23 at 14:00
















    @JouleV That depends on below of, I'll improve soon.

    – CarLaTeX
    Apr 23 at 12:58





    @JouleV That depends on below of, I'll improve soon.

    – CarLaTeX
    Apr 23 at 12:58




    1




    1





    @JouleV Yes, that's also a good solution, see my now.

    – CarLaTeX
    Apr 23 at 13:05





    @JouleV Yes, that's also a good solution, see my now.

    – CarLaTeX
    Apr 23 at 13:05













    @CarLaTeX: Thanks for your solution - exactly what I needed.

    – PS.
    Apr 23 at 13:59





    @CarLaTeX: Thanks for your solution - exactly what I needed.

    – PS.
    Apr 23 at 13:59













    @PS. You're welcome! Thank you for accepting my answer!

    – CarLaTeX
    Apr 23 at 14:00





    @PS. You're welcome! Thank you for accepting my answer!

    – CarLaTeX
    Apr 23 at 14:00











    4














    Why don't use a simple table for that?



    documentclass[margin=3]standalone
    usepackagecolortbl
    usepackagexcolor
    begindocument
    renewcommandarraystretch1.5
    begintabularll
    hline
    rowcolorredlarge HeaderOne & large HeaderTwo\hline
    rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
    hline
    endtabular
    enddocument


    enter image description here



    If you want to use this table inside a TikZ picture, simply place it inside a node.



    documentclass[margin=3,tikz]standalone
    usepackagecolortbl
    usepackagexcolor
    begindocument
    tikznoderenewcommandarraystretch1.5%
    begintabularll
    hline
    rowcolorredlarge HeaderOne & large HeaderTwo\hline
    rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
    hline
    endtabular;
    enddocument


    With pure TikZ it is also not that complicated. No need of PGF layers. However, I don't recommend this way.



    documentclass[margin=3,tikz]standalone
    usetikzlibrarypositioning
    begindocument
    begintikzpicture[node distance=0pt,inner sep=7pt]
    node[text width=3cm,font=largecolorwhite,fill=red] (header1) HeaderOne;
    node[text width=3cm,below=of header1,fill=gray!20] (text1) Short text;
    node[text width=13cm,font=largecolorwhite,fill=red,right=-pgflinewidth of header1] (header2) HeaderTwo;
    node[text width=13cm,below=of header2,fill=gray!20] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;
    draw (header1.north west) -- (header2.north east)
    (header1.south west) -- (header2.south east)
    (text1.south west) -- (text2.south east);
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer





























      4














      Why don't use a simple table for that?



      documentclass[margin=3]standalone
      usepackagecolortbl
      usepackagexcolor
      begindocument
      renewcommandarraystretch1.5
      begintabularll
      hline
      rowcolorredlarge HeaderOne & large HeaderTwo\hline
      rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
      hline
      endtabular
      enddocument


      enter image description here



      If you want to use this table inside a TikZ picture, simply place it inside a node.



      documentclass[margin=3,tikz]standalone
      usepackagecolortbl
      usepackagexcolor
      begindocument
      tikznoderenewcommandarraystretch1.5%
      begintabularll
      hline
      rowcolorredlarge HeaderOne & large HeaderTwo\hline
      rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
      hline
      endtabular;
      enddocument


      With pure TikZ it is also not that complicated. No need of PGF layers. However, I don't recommend this way.



      documentclass[margin=3,tikz]standalone
      usetikzlibrarypositioning
      begindocument
      begintikzpicture[node distance=0pt,inner sep=7pt]
      node[text width=3cm,font=largecolorwhite,fill=red] (header1) HeaderOne;
      node[text width=3cm,below=of header1,fill=gray!20] (text1) Short text;
      node[text width=13cm,font=largecolorwhite,fill=red,right=-pgflinewidth of header1] (header2) HeaderTwo;
      node[text width=13cm,below=of header2,fill=gray!20] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;
      draw (header1.north west) -- (header2.north east)
      (header1.south west) -- (header2.south east)
      (text1.south west) -- (text2.south east);
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer



























        4












        4








        4







        Why don't use a simple table for that?



        documentclass[margin=3]standalone
        usepackagecolortbl
        usepackagexcolor
        begindocument
        renewcommandarraystretch1.5
        begintabularll
        hline
        rowcolorredlarge HeaderOne & large HeaderTwo\hline
        rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
        hline
        endtabular
        enddocument


        enter image description here



        If you want to use this table inside a TikZ picture, simply place it inside a node.



        documentclass[margin=3,tikz]standalone
        usepackagecolortbl
        usepackagexcolor
        begindocument
        tikznoderenewcommandarraystretch1.5%
        begintabularll
        hline
        rowcolorredlarge HeaderOne & large HeaderTwo\hline
        rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
        hline
        endtabular;
        enddocument


        With pure TikZ it is also not that complicated. No need of PGF layers. However, I don't recommend this way.



        documentclass[margin=3,tikz]standalone
        usetikzlibrarypositioning
        begindocument
        begintikzpicture[node distance=0pt,inner sep=7pt]
        node[text width=3cm,font=largecolorwhite,fill=red] (header1) HeaderOne;
        node[text width=3cm,below=of header1,fill=gray!20] (text1) Short text;
        node[text width=13cm,font=largecolorwhite,fill=red,right=-pgflinewidth of header1] (header2) HeaderTwo;
        node[text width=13cm,below=of header2,fill=gray!20] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;
        draw (header1.north west) -- (header2.north east)
        (header1.south west) -- (header2.south east)
        (text1.south west) -- (text2.south east);
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer















        Why don't use a simple table for that?



        documentclass[margin=3]standalone
        usepackagecolortbl
        usepackagexcolor
        begindocument
        renewcommandarraystretch1.5
        begintabularll
        hline
        rowcolorredlarge HeaderOne & large HeaderTwo\hline
        rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
        hline
        endtabular
        enddocument


        enter image description here



        If you want to use this table inside a TikZ picture, simply place it inside a node.



        documentclass[margin=3,tikz]standalone
        usepackagecolortbl
        usepackagexcolor
        begindocument
        tikznoderenewcommandarraystretch1.5%
        begintabularll
        hline
        rowcolorredlarge HeaderOne & large HeaderTwo\hline
        rowcolorgray!20 Short text & A long line of text. A long line of text. A long line of text. A long line of text.\
        hline
        endtabular;
        enddocument


        With pure TikZ it is also not that complicated. No need of PGF layers. However, I don't recommend this way.



        documentclass[margin=3,tikz]standalone
        usetikzlibrarypositioning
        begindocument
        begintikzpicture[node distance=0pt,inner sep=7pt]
        node[text width=3cm,font=largecolorwhite,fill=red] (header1) HeaderOne;
        node[text width=3cm,below=of header1,fill=gray!20] (text1) Short text;
        node[text width=13cm,font=largecolorwhite,fill=red,right=-pgflinewidth of header1] (header2) HeaderTwo;
        node[text width=13cm,below=of header2,fill=gray!20] (text2) A long line of text. A long line of text. A long line of text. A long line of text.;
        draw (header1.north west) -- (header2.north east)
        (header1.south west) -- (header2.south east)
        (text1.south west) -- (text2.south east);
        endtikzpicture
        enddocument


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 23 at 13:11

























        answered Apr 23 at 12:39









        JouleVJouleV

        16.1k22667




        16.1k22667




















            PS. is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            PS. is a new contributor. Be nice, and check out our Code of Conduct.












            PS. is a new contributor. Be nice, and check out our Code of Conduct.











            PS. is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486187%2ftikz-create-rectangle-with-same-width-as-the-picture%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

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림