0

I want to get my section header as a single line, but it jumpped to a next line as shown. How to fix it? section title

This is the template I'm using.

\documentclass[12pt, twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{marginnote}
\usepackage{ragged2e}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}\usetikzlibrary{shapes.misc}
\usepackage{mathrsfs}                  
\usepackage{xcolor}
\usepackage{geometry}
\geometry{paperheight=10in,paperwidth=8in, inner=20mm, outer=70mm, bottom=30mm, top=20mm,    marginparsep=5mm,   marginparwidth=50mm}


\definecolor{inchworm}{rgb}{0.7, 0.93, 0.36}

\titleformat{\section}[block]%              
{\large\bfseries%
    \tikz[overlay] \shade[left color=inchworm,right color=white,] (-0.1,-1ex) rectangle (\textwidth,1em);}%    
{\thesection}%                   
{1em}%
{#1}



\begin{document}
\setcounter{chapter}{1}
\section{Common Logarithm and Natural Logarithm}
\marginnote{
    \begin{center}

        The logarithm of $N$ to the base 10 $(\log_{10}N)$ is said to be a common logarithm, 
        and is usually written as $\log N$ (omitting the base)

\end{center}}[-8ex]
\end{document}
  • 3
    Can you post a minimal working example which illustrates your problem? – Niranjan Feb 9 at 10:41
  • This is the command I used for section \titleformat{\section}[block]% {\large\bfseries% \tikz[overlay] \shade[left color=inchworm,right color=white,] (-0.1,-1ex) rectangle (\textwidth,1em);}% {\thesection}% {1em}% {#1} – Thurein Minn Feb 9 at 10:48
  • 3
    Could you please create a complete small document that allows others to reproduce the output you get? Linebreaks might depend on the documentclass, font size, margins,... that you use. – leandriis Feb 9 at 11:00
  • 1
    The section title currently can't fit into the textwidth. (Add the showframe option to the geometry package to see a visual representation of the textblock and the margins.) – leandriis Feb 9 at 11:31
  • Try to rephrase title, to something as \section{Common and Natural Algorithm} ... or you may looking for ragged right section title? In this case add to document preamble \usepackage{sectsty} \allsectionsfont{\raggedright} – Zarko Feb 9 at 11:55

Your Answer

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

Browse other questions tagged or ask your own question.