Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[12pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0.5cm,trim right=2.5cm] {%
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (a) at (2.5cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+3cm,-0.75ex);
}
}

\newcommand\subtitlebar{%
\tikz[baseline,trim left=1cm,trim right=3.05cm] {%
    \node[
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3.05cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}

\titleformat{\subsection}{\normalfont\sf}{\subtitlebar}{0.2cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{-2cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2.15cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}
\begin{document}
\chapter{This is a test}
\section{Section}
\lipsum[4-5]
\subsection{Subsection}
\lipsum[9]
\end{document}

This code , generates the section styles as follows : How do I remove the lines (the red lines). and increase the font size of the section name and change the font size

enter image description here

share|improve this question
    
Comment out the line in the \subtitlebar command that reads: \draw[color=red!70!blue, ... -0.75ex); and add, say \large between \normalfont and \sf in the \titleformat command. (Untested; and assumes you want to keep the red 'ball'...) –  jon Feb 11 at 15:50

1 Answer 1

up vote 7 down vote accepted

Remove \titlebar and \subtitlebar from \titleformat and adjust the spacings.

In the case of sections, change your current definitions from

\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2.15cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

to

\titleformat{\section}{\LARGE\sffamily}{}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

instead of \LARGE, use any other of the font size switches or even \fontsize{}{}\selectfont.

Similar modifications will be needed for subsections.

A complete example, using your code with the modifications suggested:

\documentclass[12pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0.5cm,trim right=2.5cm] {%
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (a) at (2.5cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+3cm,-0.75ex);
}
}

\newcommand\subtitlebar{%
\tikz[baseline,trim left=1cm,trim right=3.05cm] {%
    \node[
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3.05cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}

\titleformat{\subsection}{\normalfont\large\sffamily}{}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\titleformat{\section}{\LARGE\sffamily}{}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}
\begin{document}
\chapter{This is a test}
\section{Section}
\lipsum[4-5]
\subsection{Subsection}
\lipsum[9]
\end{document}

enter image description here

If you want to remove the rule but keeping the dot, you can define a commad for the dot:

\newcommand\titledot{%
\tikz[baseline=-0.65ex] {%
\path[fill=red!70!blue] (0,0) circle (.5ex);
  }
}

and then use

\titleformat{\section}{\LARGE\sffamily}{\llap{\titledot}}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

An example:

\documentclass[12pt]{book}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0.5cm,trim right=2.5cm] {%
    \node [
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (a) at (2.5cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (a.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+3cm,-0.75ex);
}
}

\newcommand\subtitlebar{%
\tikz[baseline,trim left=1cm,trim right=3.05cm] {%
    \node[
        text = red!70!green,
        anchor= base east,
        minimum height=3.5ex] (b) at (3.05cm,0.6ex) {%
    };
   \path[fill=red!70!blue] (b.east) circle (.5ex);
   \draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}

\newcommand\titledot{%
\tikz[baseline=-0.65ex] {%
\path[fill=red!70!blue] (0,0) circle (.5ex);
  }
}

\titleformat{\subsection}{\normalfont\large\sffamily}{\llap{\titledot}}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}


\titleformat{\section}{\LARGE\sffamily}{\llap{\titledot}}{0cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}
\begin{document}
\chapter{This is a test}
\section{Section}
\lipsum[4-5]
\subsection{Subsection}
\lipsum[9]
\end{document}

enter image description here

By the way, \sf is a TeX command which shouldn't be used anymore in modern LaTeX documents; use \sffamily instead.

share|improve this answer
    
How to modify the font size and style of section name? –  subham soni Feb 11 at 16:06
    
@subhamsoni I already explained how to change the font size in my answer. What do you mean by changing the style? Do you want to use a different font? Which one? –  Gonzalo Medina Feb 11 at 16:08
    
like Verdina or Segoe UI with 36 pt –  subham soni Feb 11 at 16:18
1  
@subhamsoni Are those t1 fonts or are you using TrueType fonts and xelatex? For the size, instead of \LARGE, use \fontsize{36}{43}\selectfont and make sure the fonts are scalable. –  Gonzalo Medina Feb 11 at 16:20
    
@subhamsoni assuming a t1 font like the given by verdana package, you can use \fontfamily{vna}\fontsize{36}{43}\selectfont. Of course, this requires the font to be installed. –  Gonzalo Medina Feb 11 at 16:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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