Headings with coloured boxes












0















I am needing to write a risk assessment report, the headings within the report are risks that have been discovered, next to each of the headings/risks I'm needing to use a key or coloured boxes to highlight the severity of the risk in question, how am I able to do this in LaTeX, a brief mock up example from word would look like the attached picture.



I'm using the hyperref package to create the menu structure in the PDF menu.



Example



I tried the following from the comments below.



{section{Heading} color{red} rule{0.2in}{0.2in}}


Whilst this gives me a box, I'd of liked to of had the border if possible, and also for it to be on the same line as the heading, with the above code the box is on the next line down with the body text for that heading.



The following code gives errors, but otherwise does what I am after albeit no border around the box..



section{Heading color{red} rule{0.2in}{0.2in}}









share|improve this question




















  • 2





    Please show us what you have tried so far!

    – Kurt
    2 hours ago






  • 2





    Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

    – Christian Hupfer
    2 hours ago






  • 3





    If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

    – Sigur
    2 hours ago
















0















I am needing to write a risk assessment report, the headings within the report are risks that have been discovered, next to each of the headings/risks I'm needing to use a key or coloured boxes to highlight the severity of the risk in question, how am I able to do this in LaTeX, a brief mock up example from word would look like the attached picture.



I'm using the hyperref package to create the menu structure in the PDF menu.



Example



I tried the following from the comments below.



{section{Heading} color{red} rule{0.2in}{0.2in}}


Whilst this gives me a box, I'd of liked to of had the border if possible, and also for it to be on the same line as the heading, with the above code the box is on the next line down with the body text for that heading.



The following code gives errors, but otherwise does what I am after albeit no border around the box..



section{Heading color{red} rule{0.2in}{0.2in}}









share|improve this question




















  • 2





    Please show us what you have tried so far!

    – Kurt
    2 hours ago






  • 2





    Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

    – Christian Hupfer
    2 hours ago






  • 3





    If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

    – Sigur
    2 hours ago














0












0








0








I am needing to write a risk assessment report, the headings within the report are risks that have been discovered, next to each of the headings/risks I'm needing to use a key or coloured boxes to highlight the severity of the risk in question, how am I able to do this in LaTeX, a brief mock up example from word would look like the attached picture.



I'm using the hyperref package to create the menu structure in the PDF menu.



Example



I tried the following from the comments below.



{section{Heading} color{red} rule{0.2in}{0.2in}}


Whilst this gives me a box, I'd of liked to of had the border if possible, and also for it to be on the same line as the heading, with the above code the box is on the next line down with the body text for that heading.



The following code gives errors, but otherwise does what I am after albeit no border around the box..



section{Heading color{red} rule{0.2in}{0.2in}}









share|improve this question
















I am needing to write a risk assessment report, the headings within the report are risks that have been discovered, next to each of the headings/risks I'm needing to use a key or coloured boxes to highlight the severity of the risk in question, how am I able to do this in LaTeX, a brief mock up example from word would look like the attached picture.



I'm using the hyperref package to create the menu structure in the PDF menu.



Example



I tried the following from the comments below.



{section{Heading} color{red} rule{0.2in}{0.2in}}


Whilst this gives me a box, I'd of liked to of had the border if possible, and also for it to be on the same line as the heading, with the above code the box is on the next line down with the body text for that heading.



The following code gives errors, but otherwise does what I am after albeit no border around the box..



section{Heading color{red} rule{0.2in}{0.2in}}






boxes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







AeroMaxx

















asked 2 hours ago









AeroMaxxAeroMaxx

284




284








  • 2





    Please show us what you have tried so far!

    – Kurt
    2 hours ago






  • 2





    Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

    – Christian Hupfer
    2 hours ago






  • 3





    If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

    – Sigur
    2 hours ago














  • 2





    Please show us what you have tried so far!

    – Kurt
    2 hours ago






  • 2





    Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

    – Christian Hupfer
    2 hours ago






  • 3





    If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

    – Sigur
    2 hours ago








2




2





Please show us what you have tried so far!

– Kurt
2 hours ago





Please show us what you have tried so far!

– Kurt
2 hours ago




2




2





Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

– Christian Hupfer
2 hours ago





Well, is the box always of the same width or does the width of the box indicate the risk? The box is pretty easy with TikZ, but how is the heading done?

– Christian Hupfer
2 hours ago




3




3





If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

– Sigur
2 hours ago





If you need just a rectangle without border, a simple rule{}{} with textcolor{}{} should work.

– Sigur
2 hours ago










1 Answer
1






active

oldest

votes


















0














mwe



documentclass{article}
usepackage{xcolor}
begin{document}

defrisk#1{fcolorbox{black}{red}{color{red}makebox[#1em]{x}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

vspace{1cm}

defrisk#1{{fboxsep0ptprotectfbox{color{red}rule{#1em}{1ex}}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

end{document}


Note that used just as sowed in the above MWE, the rule will be printed also in the table of contents and page headings as is really part of the section title, but you can use the optional argument of section to supply a short title without the rule or anything else, as the risk level as a number instas of a bar. If you are too lazy to type the section title twice, there is one way to simplify:



documentclass{article}
defrisk#1:#2 {section[#1 (risk level: #2)]{#1 fboxsep0ptprotectfbox{color{red}rule{#2em}{1ex}}}}
usepackage{xcolor}
usepackage[linkcolor=blue,colorlinks]{hyperref}
begin{document}
tableofcontents
risk Tipple:1
risk Drive a car:3
risk Tipple and drive a car:10
end{document}


mwe2






share|improve this answer


























  • Just watch for entries in the ToC, or in the PDF ToC.

    – Werner
    42 mins ago











  • @Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

    – Fran
    32 mins 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%2f473402%2fheadings-with-coloured-boxes%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









0














mwe



documentclass{article}
usepackage{xcolor}
begin{document}

defrisk#1{fcolorbox{black}{red}{color{red}makebox[#1em]{x}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

vspace{1cm}

defrisk#1{{fboxsep0ptprotectfbox{color{red}rule{#1em}{1ex}}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

end{document}


Note that used just as sowed in the above MWE, the rule will be printed also in the table of contents and page headings as is really part of the section title, but you can use the optional argument of section to supply a short title without the rule or anything else, as the risk level as a number instas of a bar. If you are too lazy to type the section title twice, there is one way to simplify:



documentclass{article}
defrisk#1:#2 {section[#1 (risk level: #2)]{#1 fboxsep0ptprotectfbox{color{red}rule{#2em}{1ex}}}}
usepackage{xcolor}
usepackage[linkcolor=blue,colorlinks]{hyperref}
begin{document}
tableofcontents
risk Tipple:1
risk Drive a car:3
risk Tipple and drive a car:10
end{document}


mwe2






share|improve this answer


























  • Just watch for entries in the ToC, or in the PDF ToC.

    – Werner
    42 mins ago











  • @Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

    – Fran
    32 mins ago


















0














mwe



documentclass{article}
usepackage{xcolor}
begin{document}

defrisk#1{fcolorbox{black}{red}{color{red}makebox[#1em]{x}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

vspace{1cm}

defrisk#1{{fboxsep0ptprotectfbox{color{red}rule{#1em}{1ex}}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

end{document}


Note that used just as sowed in the above MWE, the rule will be printed also in the table of contents and page headings as is really part of the section title, but you can use the optional argument of section to supply a short title without the rule or anything else, as the risk level as a number instas of a bar. If you are too lazy to type the section title twice, there is one way to simplify:



documentclass{article}
defrisk#1:#2 {section[#1 (risk level: #2)]{#1 fboxsep0ptprotectfbox{color{red}rule{#2em}{1ex}}}}
usepackage{xcolor}
usepackage[linkcolor=blue,colorlinks]{hyperref}
begin{document}
tableofcontents
risk Tipple:1
risk Drive a car:3
risk Tipple and drive a car:10
end{document}


mwe2






share|improve this answer


























  • Just watch for entries in the ToC, or in the PDF ToC.

    – Werner
    42 mins ago











  • @Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

    – Fran
    32 mins ago
















0












0








0







mwe



documentclass{article}
usepackage{xcolor}
begin{document}

defrisk#1{fcolorbox{black}{red}{color{red}makebox[#1em]{x}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

vspace{1cm}

defrisk#1{{fboxsep0ptprotectfbox{color{red}rule{#1em}{1ex}}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

end{document}


Note that used just as sowed in the above MWE, the rule will be printed also in the table of contents and page headings as is really part of the section title, but you can use the optional argument of section to supply a short title without the rule or anything else, as the risk level as a number instas of a bar. If you are too lazy to type the section title twice, there is one way to simplify:



documentclass{article}
defrisk#1:#2 {section[#1 (risk level: #2)]{#1 fboxsep0ptprotectfbox{color{red}rule{#2em}{1ex}}}}
usepackage{xcolor}
usepackage[linkcolor=blue,colorlinks]{hyperref}
begin{document}
tableofcontents
risk Tipple:1
risk Drive a car:3
risk Tipple and drive a car:10
end{document}


mwe2






share|improve this answer















mwe



documentclass{article}
usepackage{xcolor}
begin{document}

defrisk#1{fcolorbox{black}{red}{color{red}makebox[#1em]{x}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

vspace{1cm}

defrisk#1{{fboxsep0ptprotectfbox{color{red}rule{#1em}{1ex}}}}
setcounter{section}{0}section*{Risk assessments:}
section{Tipple risk{1}}
section{Drive a car risk{3}}
section{Tipple and drive a car risk{10}}

end{document}


Note that used just as sowed in the above MWE, the rule will be printed also in the table of contents and page headings as is really part of the section title, but you can use the optional argument of section to supply a short title without the rule or anything else, as the risk level as a number instas of a bar. If you are too lazy to type the section title twice, there is one way to simplify:



documentclass{article}
defrisk#1:#2 {section[#1 (risk level: #2)]{#1 fboxsep0ptprotectfbox{color{red}rule{#2em}{1ex}}}}
usepackage{xcolor}
usepackage[linkcolor=blue,colorlinks]{hyperref}
begin{document}
tableofcontents
risk Tipple:1
risk Drive a car:3
risk Tipple and drive a car:10
end{document}


mwe2







share|improve this answer














share|improve this answer



share|improve this answer








edited 1 min ago

























answered 51 mins ago









FranFran

52.2k6115178




52.2k6115178













  • Just watch for entries in the ToC, or in the PDF ToC.

    – Werner
    42 mins ago











  • @Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

    – Fran
    32 mins ago





















  • Just watch for entries in the ToC, or in the PDF ToC.

    – Werner
    42 mins ago











  • @Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

    – Fran
    32 mins ago



















Just watch for entries in the ToC, or in the PDF ToC.

– Werner
42 mins ago





Just watch for entries in the ToC, or in the PDF ToC.

– Werner
42 mins ago













@Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

– Fran
32 mins ago







@Werner I do not see any other problem that in case of a ToC you must use the optional argument of section, e.g., section[Tipple]{Tipple risk{1}}.

– Fran
32 mins 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%2f473402%2fheadings-with-coloured-boxes%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

Lallio

Unable to find Lightning Node

Futebolista