to make it clear, I would like to reproduce this:
in a way that the lines automatically fill the space on the right and left of the word in the center (as I need to use it for several titles).
Thank you very much!
to make it clear, I would like to reproduce this:
in a way that the lines automatically fill the space on the right and left of the word in the center (as I need to use it for several titles).
Thank you very much!
Your question is not very clear. I assume, that wide of this line is \textwidth
, so it is something like this?
Edit:
For compensating ident
should be before image code in document added command \noindent
.
in definition of command to draw this image the \noindent
is part of image code, so a care of positioning of suit
command is not needed anymore.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent\tikz\draw[line width=1.2ex, shorten >=1.2ex, line cap=round, gray]
(0,0) -- node[fill=white] {Suites} (\linewidth,0);
\end{document}
or this:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent\tikz{\path (0,0) -- node[inner xsep=1em] (s) {Suites} ++ (\linewidth,0);
\draw[line width=1.2ex, line cap=round, gray] (0,0) -- (s);
\draw[line width=1.2ex, shorten >=1.2ex, line cap=round, gray] (s) -- (\linewidth,0);
}
\end{document}
Edit: If you need it more than once, than defining new command can be handy:
\documentclass{article}
\usepackage{tikz}
\NewDocumentCommand\suit{m}{\par\noindent%
\tikz{\path (0,0) -- node[inner xsep=1em] (s) {#1} (\linewidth,0);
\draw[line width=1.2ex, line cap=round, gray] (0,0) -- (s);
\draw[line width=1.2ex, shorten >=1.2ex, line cap=round, gray] (s) -- (\linewidth,0);
}}
\begin{document}
\suit{SUITE}
\end{document}
Result of compilation is the same as before. This command can be used also in boxes. For example:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\NewDocumentCommand\suit{m}{\par\noindent%
\tikz{\path (0,0) -- node[inner xsep=1em] (s) {#1} (\linewidth,0);
\draw[line width=1.2ex, line cap=round, gray] (0,0) -- (s);
\draw[line width=1.2ex, shorten >=1.2ex, line cap=round, gray] (s) -- (\linewidth,0);
}}
\begin{document}
\lipsum[11]\par
\hfil\fbox{%
\parbox{0.8\textwidth}{
\suit{Start}
\lipsum[66]
\suit{The end}
}}
\end{document}
gives:
\noindent
in examples as well in definition of the command \suite
.
Zarko's answer is much more elegant than mine but since I had already been working on it I present it here as a secondary solution. (I also get Overful \hbox too wide
when running Zarko's code, probably because of this).
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning}
\newcommand{\splitheading}[1]{
\setbox0=\hbox{#1}
\noindent
\begin{tikzpicture}[
txt/.style={red,draw=none, fill=none},
line/.style={draw=none, fill=none,inner sep=0}]
\node(mid)[txt]{#1};
\node(first)[line,left = ((\textwidth-\the\wd0)/2)-6 of mid]{};
\node(second)[line,right = ((\textwidth-\the\wd0)/2)-6 of mid]{};
\path[Round Cap-Round Cap,red,line width=1ex](first)edge(mid)(mid)edge(second);
\end{tikzpicture}}
\splitheading{Suites}