Getting the width of the current containerAdjusting the width of the matrixfine-tuning of makebox widthSet...

Which country benefited the most from UN Security Council vetoes?

strTok function (thread safe, supports empty tokens, doesn't change string)

Is it legal for company to use my work email to pretend I still work there?

Codimension of non-flat locus

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

How much of data wrangling is a data scientist's job?

What's the point of deactivating Num Lock on login screens?

Modeling an IP Address

Intersection point of 2 lines defined by 2 points each

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Why can't we play rap on piano?

Is it possible to do 50 km distance without any previous training?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

Watching something be written to a file live with tail

How does quantile regression compare to logistic regression with the variable split at the quantile?

How is it possible to have an ability score that is less than 3?

Are the number of citations and number of published articles the most important criteria for a tenure promotion?

Arrow those variables!

Why is consensus so controversial in Britain?

Why are electrically insulating heatsinks so rare? Is it just cost?

Why do I get two different answers for this counting problem?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Was any UN Security Council vote triple-vetoed?

Fully-Firstable Anagram Sets



Getting the width of the current container


Adjusting the width of the matrixfine-tuning of makebox widthSet minipage width to the available spacehow to set sidebar color widthTable exceeds the page widthHow do I change the width of the table to the text width in Latex?URL reference width continues after marginWidth of the content inside `begin{center} … end{center}`Image matrix using the whole line width?Is there a global variable that reflects the current preferred table column's width?













2















I'm trying to create a generic command to write a solid heading. The width of the heading should fit into the containing environment in which the heading it rendered.



In the example below, the orange heading flows outside the table.



What command should I use to replace textwidthin the solidheading so that it will always print a width that fits into either a paragraph width or inside a table column?



enter image description here



The code to produce this is as follows:



documentclass[12pt]{article}

usepackage{xcolor}

newcommand{solidheading}[2][yellow]{
noindent colorbox{#1}{parbox[t]{textwidth}{#2}}
vskip1ex
}

usepackage{colortbl}
usepackage{fontawesome5}

newenvironment{notes}
{ noindent
begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
{cellcolor{gray}}
{LargefaEdit[regular]} bfseries{Notes}\
{cellcolor{lightgray}}
}
{
end{tabular}
}


begin{document}

solidheading[pink]{Heading outside Table}

begin{notes}
solidheading[orange]{Don't forget}
Smile and say hello.newline
Happy makes happy.
end{notes}

end{document}









share|improve this question



























    2















    I'm trying to create a generic command to write a solid heading. The width of the heading should fit into the containing environment in which the heading it rendered.



    In the example below, the orange heading flows outside the table.



    What command should I use to replace textwidthin the solidheading so that it will always print a width that fits into either a paragraph width or inside a table column?



    enter image description here



    The code to produce this is as follows:



    documentclass[12pt]{article}

    usepackage{xcolor}

    newcommand{solidheading}[2][yellow]{
    noindent colorbox{#1}{parbox[t]{textwidth}{#2}}
    vskip1ex
    }

    usepackage{colortbl}
    usepackage{fontawesome5}

    newenvironment{notes}
    { noindent
    begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
    {cellcolor{gray}}
    {LargefaEdit[regular]} bfseries{Notes}\
    {cellcolor{lightgray}}
    }
    {
    end{tabular}
    }


    begin{document}

    solidheading[pink]{Heading outside Table}

    begin{notes}
    solidheading[orange]{Don't forget}
    Smile and say hello.newline
    Happy makes happy.
    end{notes}

    end{document}









    share|improve this question

























      2












      2








      2








      I'm trying to create a generic command to write a solid heading. The width of the heading should fit into the containing environment in which the heading it rendered.



      In the example below, the orange heading flows outside the table.



      What command should I use to replace textwidthin the solidheading so that it will always print a width that fits into either a paragraph width or inside a table column?



      enter image description here



      The code to produce this is as follows:



      documentclass[12pt]{article}

      usepackage{xcolor}

      newcommand{solidheading}[2][yellow]{
      noindent colorbox{#1}{parbox[t]{textwidth}{#2}}
      vskip1ex
      }

      usepackage{colortbl}
      usepackage{fontawesome5}

      newenvironment{notes}
      { noindent
      begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
      {cellcolor{gray}}
      {LargefaEdit[regular]} bfseries{Notes}\
      {cellcolor{lightgray}}
      }
      {
      end{tabular}
      }


      begin{document}

      solidheading[pink]{Heading outside Table}

      begin{notes}
      solidheading[orange]{Don't forget}
      Smile and say hello.newline
      Happy makes happy.
      end{notes}

      end{document}









      share|improve this question














      I'm trying to create a generic command to write a solid heading. The width of the heading should fit into the containing environment in which the heading it rendered.



      In the example below, the orange heading flows outside the table.



      What command should I use to replace textwidthin the solidheading so that it will always print a width that fits into either a paragraph width or inside a table column?



      enter image description here



      The code to produce this is as follows:



      documentclass[12pt]{article}

      usepackage{xcolor}

      newcommand{solidheading}[2][yellow]{
      noindent colorbox{#1}{parbox[t]{textwidth}{#2}}
      vskip1ex
      }

      usepackage{colortbl}
      usepackage{fontawesome5}

      newenvironment{notes}
      { noindent
      begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
      {cellcolor{gray}}
      {LargefaEdit[regular]} bfseries{Notes}\
      {cellcolor{lightgray}}
      }
      {
      end{tabular}
      }


      begin{document}

      solidheading[pink]{Heading outside Table}

      begin{notes}
      solidheading[orange]{Don't forget}
      Smile and say hello.newline
      Happy makes happy.
      end{notes}

      end{document}






      width






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      JackJack

      445159




      445159






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can use linewidth instead of textwidth:



          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth <==============
          vskip1ex
          }


          With the complete code



          documentclass[12pt]{article}

          usepackage{xcolor}

          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth
          vskip1ex
          }

          usepackage{colortbl}
          usepackage{fontawesome5}

          newenvironment{notes}
          { noindent
          begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
          {cellcolor{gray}}
          {LargefaEdit[regular]} bfseries{Notes}\
          {cellcolor{lightgray}}
          }
          {
          end{tabular}
          }


          begin{document}

          solidheading[pink]{Heading outside Table}

          begin{notes}
          solidheading[orange]{Don't forget}
          Smile and say hello.newline
          Happy makes happy.
          end{notes}

          end{document}


          you the result:



          result






          share|improve this answer
























          • Thanks Kurt, sometimes the answer is so simple ;-)

            – Jack
            3 hours ago











          • @Jack yes, sometimes it is :-)

            – Kurt
            2 hours ago












          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%2f483452%2fgetting-the-width-of-the-current-container%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can use linewidth instead of textwidth:



          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth <==============
          vskip1ex
          }


          With the complete code



          documentclass[12pt]{article}

          usepackage{xcolor}

          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth
          vskip1ex
          }

          usepackage{colortbl}
          usepackage{fontawesome5}

          newenvironment{notes}
          { noindent
          begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
          {cellcolor{gray}}
          {LargefaEdit[regular]} bfseries{Notes}\
          {cellcolor{lightgray}}
          }
          {
          end{tabular}
          }


          begin{document}

          solidheading[pink]{Heading outside Table}

          begin{notes}
          solidheading[orange]{Don't forget}
          Smile and say hello.newline
          Happy makes happy.
          end{notes}

          end{document}


          you the result:



          result






          share|improve this answer
























          • Thanks Kurt, sometimes the answer is so simple ;-)

            – Jack
            3 hours ago











          • @Jack yes, sometimes it is :-)

            – Kurt
            2 hours ago
















          1














          You can use linewidth instead of textwidth:



          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth <==============
          vskip1ex
          }


          With the complete code



          documentclass[12pt]{article}

          usepackage{xcolor}

          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth
          vskip1ex
          }

          usepackage{colortbl}
          usepackage{fontawesome5}

          newenvironment{notes}
          { noindent
          begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
          {cellcolor{gray}}
          {LargefaEdit[regular]} bfseries{Notes}\
          {cellcolor{lightgray}}
          }
          {
          end{tabular}
          }


          begin{document}

          solidheading[pink]{Heading outside Table}

          begin{notes}
          solidheading[orange]{Don't forget}
          Smile and say hello.newline
          Happy makes happy.
          end{notes}

          end{document}


          you the result:



          result






          share|improve this answer
























          • Thanks Kurt, sometimes the answer is so simple ;-)

            – Jack
            3 hours ago











          • @Jack yes, sometimes it is :-)

            – Kurt
            2 hours ago














          1












          1








          1







          You can use linewidth instead of textwidth:



          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth <==============
          vskip1ex
          }


          With the complete code



          documentclass[12pt]{article}

          usepackage{xcolor}

          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth
          vskip1ex
          }

          usepackage{colortbl}
          usepackage{fontawesome5}

          newenvironment{notes}
          { noindent
          begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
          {cellcolor{gray}}
          {LargefaEdit[regular]} bfseries{Notes}\
          {cellcolor{lightgray}}
          }
          {
          end{tabular}
          }


          begin{document}

          solidheading[pink]{Heading outside Table}

          begin{notes}
          solidheading[orange]{Don't forget}
          Smile and say hello.newline
          Happy makes happy.
          end{notes}

          end{document}


          you the result:



          result






          share|improve this answer













          You can use linewidth instead of textwidth:



          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth <==============
          vskip1ex
          }


          With the complete code



          documentclass[12pt]{article}

          usepackage{xcolor}

          newcommand{solidheading}[2][yellow]{
          noindent colorbox{#1}{parbox[t]{linewidth}{#2}} % textwidth
          vskip1ex
          }

          usepackage{colortbl}
          usepackage{fontawesome5}

          newenvironment{notes}
          { noindent
          begin{tabular}{!{color{black}vrule width 0.01textwidth}p{0.85textwidth}}
          {cellcolor{gray}}
          {LargefaEdit[regular]} bfseries{Notes}\
          {cellcolor{lightgray}}
          }
          {
          end{tabular}
          }


          begin{document}

          solidheading[pink]{Heading outside Table}

          begin{notes}
          solidheading[orange]{Don't forget}
          Smile and say hello.newline
          Happy makes happy.
          end{notes}

          end{document}


          you the result:



          result







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          KurtKurt

          40.8k950164




          40.8k950164













          • Thanks Kurt, sometimes the answer is so simple ;-)

            – Jack
            3 hours ago











          • @Jack yes, sometimes it is :-)

            – Kurt
            2 hours ago



















          • Thanks Kurt, sometimes the answer is so simple ;-)

            – Jack
            3 hours ago











          • @Jack yes, sometimes it is :-)

            – Kurt
            2 hours ago

















          Thanks Kurt, sometimes the answer is so simple ;-)

          – Jack
          3 hours ago





          Thanks Kurt, sometimes the answer is so simple ;-)

          – Jack
          3 hours ago













          @Jack yes, sometimes it is :-)

          – Kurt
          2 hours ago





          @Jack yes, sometimes it is :-)

          – Kurt
          2 hours ago


















          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%2f483452%2fgetting-the-width-of-the-current-container%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

          Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

          Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

          How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...