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.

I'm writing a document optimized for mobile usage, and as such I want to conserve my space. The spacing that titlesec adds to sections, subsections, etc. is getting somewhat annoying. Is there a (simple) method to remove this? My desire is to just change the look of the title while retaining all LaTeX default spacing, etc.

The sectsty package doesn't add any spacing and works great, but I'd like to make use of some of titlesec's features.

I've looked at the following questions and they don't seem to fix my problem:

Please close this if I've overlooked something in the solutions above.

MWE result

\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{margin=5mm, paper=a6paper, showframe=true}
\usepackage{titlesec}
\titleformat*\section{\Large}
\titleformat*\subsection{\large}
\usepackage{lipsum}
\begin{document}
\section*{Using titlesec}
\subsection*{Lorem Ipsum}
\lipsum[3]
\end{document}

Note: Remove the three titlesec lines to obtain the LaTeX default result.

share|improve this question
2  
This is a great question. Sadly enough, titlesec's formatting is not immediately setup for this kind of thing. Instead, and often very typically, you have to specify all of the options in order to change just one thing, without even knowing the defaults of the other. That's the advantage of providing a key-value driven input rather than a full argument-based macro (as titlesec does). What's needed here is something like titleseckv (doesn't exist) that does everything titlesec does, but allows for a `key-value interface with LaTeX defaults otherwise. –  Werner Oct 26 '12 at 23:16

1 Answer 1

up vote 8 down vote accepted

The package titlesec adds \strut in some places. In your case you have to defeat this behavior in three places:

\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{margin=5mm, paper=a6paper, showframe=true}

\usepackage{titlesec}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\ttl@select}{\strut}{}{}{}
\patchcmd{\ttlh@hang}{\strut}{}{}{}
\patchcmd{\ttlh@hang}{\strut}{}{}{}
\makeatother

\titleformat*\section{\Large}
\titleformat*\subsection{\large}

\usepackage{lipsum}
\begin{document}

\section*{Using titlesec}
\subsection*{Lorem Ipsum}
\lipsum[3]
\end{document}

The macros involved are \ttl@select and \ttlh@hang (in the second one \strut appears twice. If other styles are selected it may be necessary to patch \ttlh@display or \ttlh@runin.

share|improve this answer

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.