6

enter image description here

This is what I want.

MWE for test:

\documentclass[UTF8]{article}

\begin{document}
    \section{section I}
        \subsection{subsection I}
    \section{section II}
        \subsection{subsection II}
\end{document}

I would like to have a solution, that suitable for most documentclass.

Thank you all in advance!

  • 2
    Can you make a minimal working example (MWE) that also shows which documetclass you are using? – user36296 May 25 '18 at 17:32
  • @samcarter just normal article class, I would like to have a general solution, that suitable for most documentclass – sun0727 May 25 '18 at 18:01
11

You already added titlesec to your tags, so you could use this package. For example like this:

\documentclass[utf8]{article}
\usepackage{titlesec,xcolor}

\titleformat{\section}{\bfseries\Large}{\textcolor{orange}{\rule[-3pt]{5pt}{1em}}}{5pt}{}

\begin{document}
    \section{section I}
        \subsection{subsection I}
    \section{section II}
        \subsection{subsection II}
\end{document}

enter image description here

6

For example into stix (or fontawesome) fonts there are many nice symbols. I add a alternative MWE for your question.

enter image description here

\documentclass{article}
\usepackage{lipsum,xcolor}
\usepackage{stix}

\def\orr{\rlap{\protect\makebox[-2cm]{$\color{orange}\vrectangleblack$}}}

\begin{document}
\section{\orr section I}
        \subsection{subsection I}
    \section{\orr section II}
        \subsection{subsection II}
\end{document}
  • 1
    Why I have had a negative down? Can I have an explanation? – Sebastiano May 25 '18 at 21:07
  • +1 from me - nice approach. – Dr. Manuel Kuehner May 25 '18 at 21:19
  • @Dr.ManuelKuehner First of all, I thank you for your vote. With so much sincerity in this period I'm getting negative votes without understanding the cause. Thanks again. – Sebastiano May 25 '18 at 21:20
  • I do not see any reason for a down vote. – Dr. Manuel Kuehner May 25 '18 at 21:22
  • 1
    I think @samcarter means that your approach creates some negative effects on the PDF bookmarks (the [-2cm] bit). – Dr. Manuel Kuehner May 25 '18 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.