1

Problem description

I am trying to make some custom Tikz sections, but I am lost at finding a way to make the Tikz box stretch accordingly to its text inside. In this example "Professional Experience" is too long for the lengths I have defined.

enter image description here

with associated code:

\documentclass{article}
\usepackage{geometry}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,calc}
\usetikzlibrary{positioning,calc}

\definecolor{lightorange}{HTML}{ffa500}


\newcommand\SecTitle[4]{%
    \begin{tikzpicture}
    
    \node (A) [rectangle,minimum width=\textwidth, minimum height=1cm,color=white,fill=white, text width=\textwidth+3cm,align=left] {};
    \draw (-7.2,0) -- (\textwidth,0);
    \fill[fill=lightorange] (A.north west) -- ($(A.north west)+(3.5cm,0)$) -- ($0.45*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-2.5cm,0)$)--($(A.south west)+(3.5cm,0)$)--(A.south west);
    \node [color=white](A.north west) at ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-1cm,0)$) {\hspace{-1.25cm}\huge\textbf{\textsf{#4}}};
    
    \end{tikzpicture}
}
\titleformat{name=\section}
{\normalfont}{}{0em}
{\SecTitle{east}{west}{0\paperwidth}{#1}}

\begin{document}
    \newgeometry{left=1cm,right=1cm}
    \section{Education}
    \section{Professional Experience}
\end{document}

What I have tried

I looked at the CTAN pdf for tiks but have not found what I am looking for. I searched this Stack as well with no success. I tried changing the order in which the commands are written but that doesn't fix it.

Does anyone know how I can achieve what I am looking for ?

3

0

Browse other questions tagged .