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.

Is there an alternative for \usepackage[nobottomtitles*]{titlesec} as it messes up my automatic clearing of floatingfingure?

\documentclass{article}
\usepackage{mwe}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}

\setlength{\parindent}{0pt}

% begin preamble.tex
\usepackage[nobottomtitles*]{titlesec}
%\renewcommand{\bottomtitlespace}{.2\textheight}

\usepackage{calc}
\newlength\vimgflt
\newlength\vposflt
\newlength\vtypesetflt
\newlength\vspaceflt

\usepackage{floatflt}
\renewenvironment{description}{%
    \renewcommand{\includegraphics}[1]{\vspace{-1ex}\Oldincludegraphics[width=4cm]{##1}}
    \renewcommand{\item}[1][]{
        \settototalheight\vimgflt{##1}%
        \global\vimgflt=\vimgflt%
        ##1%
        \end{floatingfigure}%
        \setlength\vposflt\pagetotal%
        \global\vposflt=\vposflt%
        }%
    \clearflt
    \hspace{0pt}%
    \begin{floatingfigure}[l]{4cm}}%
    {}

\newcommand{\clearflt}{
    \par%
    \setlength\vtypesetflt{\dimexpr\pagetotal-\vposflt}
    \ifdim \vtypesetflt<\vimgflt \setlength\vspaceflt{\dimexpr\vimgflt-\vtypesetflt+\baselineskip} \else \setlength\vspaceflt{0pt} \fi
    \vspace*{\vspaceflt}
    }

\let\Oldsection\section
\renewcommand{\section}{\clearflt\Oldsection}
% end preamble.tex

\begin{document}
\blindtext
\section{Section title}
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-a}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

\section{Section title}
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-b}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

\section{Section title}
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-c}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

\blindtext[2]
\end{document}

\usepackage[nobottomtitles*]{titlesec} mess-up

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.