I am trying to achieve something like this for the section title
----------
| title |-------------------------------------------------------------------
----------
So far I have this code using the tikz library, which I would like to use because of the flexibility and elegance it provides
\documentclass[12pt]{article}
\usepackage[sfdefault]{roboto}
\usepackage[top=1cm, left=0.5cm, right=0.5cm, bottom=0.5cm]{geometry}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\definecolor{seccolor}{RGB}{41,48,57}
\titleformat{\section}
[hang]
{\Large\bfseries}
{}
{0pt}
{\tikz{
\node[draw, rounded corners=1mm](a){\Large\bfseries\textcolor{seccolor}{}#1};
\node[draw=none] (b) at (\textwidth-2em,0) {};
\draw[] (a)--(b)}}
\begin{document}
\section{Summary}
\section{Literature Review}
\end{document}
which basically works. However a couple of this I would like to improve:
- I would like to increate the line thickness.
- I would like the line to end exactly at the right margin I specified, which isn't achieved using the above code for different section's titles' lengths.
How can I achieve these two improvements?
line width
, as for example in\node[draw, rounded corners=1mm, line width=2pt]
.draw=none
, and I was wondering why it wasn't working. What about the line length, how can I dynamically control it based on the box size so that it ends exactly at the end of the text width?