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.

Images in dictionary appear under the headword. I would like to control the behaviour of the placing with few rules. Controling of the placement should prevent undesired alignment that causes for example wider lines.

General placement:

  • If possible, place image right under the headword. If not, place in the same page. Else place on the next page.

  • Check if the page contain more images. If the page contains more than 2, place other images to the next page.

Upper placement:

  • Place image always not directly at the beginning of the page, but after at least 3 lines of the text

Lower placement:

  • Place image always not directly at the end of the page, but before at least 3 lines of the text

Example of undesired alignment

In this example, the image appears first in the page and next image alignment causes too wide lines that looks unnatural.

MWE:

\documentclass[8pt,b5paper,twocolumn]{extbook} 
\usepackage[top=2cm, headsep=0.4cm, bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{fancyhdr}
\usepackage[icelandic, czech, english]{babel}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{00A0}{~} % finds hidden non-breakable space
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\usepackage[scaled]{helvet}
\usepackage{enumitem}
\usepackage{hanging}
\usepackage{makeidx}
\usepackage{stmaryrd}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tipa}
\usepackage{fix2col}
\usepackage{dingbat}
\usepackage{manfnt}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage{color}
\usepackage{titlesec}

% pdf information
\usepackage[pdftex,colorlinks=true]{hyperref}
\hypersetup{pdftitle={PDF title},pdfauthor={PDF author}, pdfsubject={PDF subject}, pdfkeywords={PDF keywords}, linktoc=none}

% COLORS
\definecolor{darkgreen}{rgb}{0.4, 0.01, 0.24}
\definecolor{royalazure}{rgb}{0.0, 0.22, 0.66}
\definecolor{brown}{rgb}{0.4, 0.01, 0.24}

% COLORS FOR THUMB INDEXES
\definecolor{babyblueeyes}{rgb}{0.63, 0.79, 0.95}
\definecolor{unitednationsblue}{rgb}{0.36, 0.57, 0.9}
\definecolor{blue(ryb)}{rgb}{0.01, 0.28, 1.0}
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}
\definecolor{screamingreen}{rgb}{0.46, 1.0, 0.44}
\definecolor{limegreen}{rgb}{0.2, 0.8, 0.2}
\definecolor{islamicgreen}{rgb}{0.0, 0.56, 0.0}
\definecolor{upforestgreen}{rgb}{0.0, 0.27, 0.13}
\definecolor{icterine}{rgb}{0.99, 0.97, 0.37}
\definecolor{orange(colorwheel)}{rgb}{1.0, 0.5, 0.0}
\definecolor{orange-red}{rgb}{1.0, 0.27, 0.0}
\definecolor{oucrimsonred}{rgb}{0.6, 0.0, 0.0}
\definecolor{cottoncandy}{rgb}{1.0, 0.74, 0.85}
\definecolor{orchid}{rgb}{0.85, 0.44, 0.84}
\definecolor{vividcerise}{rgb}{0.85, 0.11, 0.51}
\definecolor{patriarch}{rgb}{0.5, 0.0, 0.5}

% Thumb indexes' colors
\newcommand\BoxColor{%
\ifcase\theletternum darkgreen!30\or babyblueeyes\or unitednationsblue\or blue(ryb)\or screamingreen\or limegreen\or islamicgreen\or upforestgreen\or icterine\or orange(colorwheel)\or orange-red%
\or oucrimsonred\or cottoncandy\or orchid\or vividcerise\or patriarch\or babyblueeyes\or unitednationsblue\or blue(ryb)\or screamingreen\or limegreen\or islamicgreen\or upforestgreen\or icterine\or orange(colorwheel)\or orange-red%
\or oucrimsonred\or cottoncandy\or orchid\or vividcerise\or patriarch\else darkgreen!30\fi}

%COMMANDS
\newcommand\entry[3][]{\hangpara{2em}{1}{\fontfamily{phv}\selectfont{\textbf{{#2}}}}\ 
#3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi
\par}\nopagebreak[4]
\newcommand*{\dictchar}[1]{\parbox[c][3cm][c]{2cm}{\Huge\textbf{#1}}\par}

%FANCY PAGE STYLES
\pagestyle{fancy}

% THUMB INDEXES
% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{33}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{1cm}
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{3cm}
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
(\paperheight-\thumbtopmargin-\thumbbottommargin)%
/%
\value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{0.4cm}
% style the boxes
\tikzset{
thumb/.style={
   text=white,
   minimum height=\thumbheight,
   text width=\thumbwidth,
   outer sep=0pt,
   font=\sffamily\bfseries,
}
}
\newcommand{\oddthumb}[1]{%
    % see pgfmanual.pdf for more information about this part
    \begin{tikzpicture}[remember picture, overlay]
        \node [thumb,fill=\BoxColor, text centered,anchor=north east,] at ($%
            (current page.north east)-%
            (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
        $) {#1};
   \end{tikzpicture}
 }
 \newcommand{\eventhumb}[1]{%
    % see pgfmanual.pdf for more information about this part
    \begin{tikzpicture}[remember picture, overlay]
        \node [thumb,fill=\BoxColor, text centered,anchor=north west,] at ($%
            (current page.north west)-%
            (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
        $) {#1};
   \end{tikzpicture}
 }
 % create a new command to set a new lettergroup with thumb indexes
 \newcommand{\lettergroup}[1]{%
 \fancyhead[LO]{\fontfamily{phv}\selectfont{\textbf{\rightmark}}\eventhumb{#1}}%
 \fancyhead[RE]{\fontfamily{phv}\selectfont{\textbf{\leftmark}}\oddthumb{#1}}%
 % step the counter of the letters
 \stepcounter{letternum}%
 }

 % BASIC PAGE STYLE
 \fancypagestyle{basicstyle}{%
 \fancyhf{}
 \renewcommand{\headrulewidth}{0.4pt}
 \renewcommand{\footrulewidth}{0pt}
 \fancyhead[LE,RO]{\textbf{\chaptitle}}
 \fancyhead[LO,RE]{\textbf{\thepage}}}

 % DICTIONARY PAGE STYLE
 \fancypagestyle{dictstyle}{%
 \renewcommand{\headrulewidth}{0.4pt}
 \fancyhf{}
 \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
 \fancyhead[CO,CE]{\thepage}
 \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

 \setlength{\columnsep}{20pt}
 \setlength{\columnseprule}{0.1pt}

 \titleformat{\chapter}[block]
 {\normalfont\huge\bfseries}{\thechapter.}{1em}{\Huge}
 \titlespacing*{\chapter}{20pt}{20pt}{20pt}

 % GRAPHICS PATH
 \graphicspath{/home/SomeUser/Documents/dictionary/images/}

\begin{document}
\pagestyle{dictstyle}

% the letters in alphabetical order
\lettergroup{l}
\dictchar{l L}
\entry[headword_without_special_symbols]{headword_with_symbols}{senses}
\entry[2 headword_without_special_symbols]{2 headword_with_symbols}{2 senses}.\par
\begin{center}\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}\fbox{\includegraphics[height=6cm]{SomeJPGFile.jpg}}\\ \footnotesize {Caption}\end{center}
\index{Headword - Author of Photograph, Licence}}
\entry[3 headword_without_special_symbols]{3 headword_with_symbols}{senses}
\clearpage
\end{document}
share|improve this question

closed as too localized by Frank Mittelbach, cmhughes, Stefan Kottwitz Oct 31 '12 at 15:54

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
can you elaborate on what you mean by the first 2 rules? Alos please give some MWE so that it is clear what your source looks like that is producing the placement. –  Frank Mittelbach Oct 31 '12 at 10:56
    
It seems that question [How to influence the position of float environments like figure and table in LaTeX?] (tex.stackexchange.com/questions/39017/…) answers the position. It is probably needed to use floats. My question seems unimportant and probably can be deleted. Thank you. –  chejnik Oct 31 '12 at 14:19