0

I encountered problem in which I cannot even imagine how to ask question to google. Probably I made mistake in structure of my documment and now it is not working properly.

First thing is that I need to be precise in placing figures, so I added \FloatBarrier in every image command:

\newcommand{\image}[4][40mm]{
\begin{figure}[h]%
\centering%
\fcolorbox{frameColor}{white}{\includegraphics[width=\textwidth, height = #1, keepaspectratio]{#2}}
\caption{#3}%
\label{#4}
\end{figure}%
\FloatBarrier
}

And it works fine, in most cases. There is one specific case visible in this picture:

Scaled down image creating emty space

And LaTeX code:

Klikamy znaczek plusa, który widoczny jest w dolnej części naszego bloczka \textbf{if}. Zostanie wtedy dodane miejsce na drugi warunek, oznaczony jako \textbf{else if}.

\image[59mm]{cz3/19}{Nowa sekcja else if w instrukcji warunkowej}{fig:fig3_15}

Drugi warunek wypełniamy analogicznie do pierwszego. Zmieniamy tylko od razu wartości liczbowe. W pierwszym warunku wpisujemy 200, a w drugim 500. Dodajemy też bloczki włączające i wyłączające diodę na module podłączonym do wyjścia P1.

\image[71mm]{cz3/20}{Ostateczna wersja programu z rozbudowanym warunkiem}{fig:fig3_16}

\newpage

Całość interpretujemy następująco:

\begin{enumerate}
\item Odczytaj wartość z wejścia P0 i sprawdź, czy jest mniejsza od liczby 200.

I added \newpage because some text appeared on the bottom. So seen this white space, I'd like to scale up images to be able to fill it. But if I only add 1 mm to the size, image shifts to the next page as if it is too large...

Changing size from 71 to 72 messed it up

Building this structure was a bit trial and error process so it can be messy... I noticed that this behaviour occurs (probably) only on left pages. Please help me :)

%----------------------------------------------------------------------------------------
%   INFORMATIONS
%----------------------------------------------------------------------------------------
% A%: BRUTTO PAGE SIZE: 154x216 mm (+6) / B5: 182x256
% NETTO PAGE SIZE: 148x210 mm       / B5: 176x250
% BLEED MARGIN: 3mm
% LAYOUT A5
%WARNING! zmien tez w main

%----------------------------------------------------------------------------------------
%   PACKAGES AND CONFIGURATIONS
%----------------------------------------------------------------------------------------
\usepackage[top=20mm,bottom=20mm,outer=16mm,inner=24mm,papersize={169mm,234mm}]{geometry} % Page B5 with 2mm bleed showframe
% \usepackage[top=20mm,bottom=20mm,outer=20mm,inner=25mm,papersize={182mm,256mm}]{geometry} % Page A5 with 3mm bleed
% \usepackage{graphicx} % Required for including pictures
\usepackage[export]{adjustbox}
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage{pdfpages}
%\footskip=0pt
%\flushbottom
\usepackage{showframe}

\usepackage[hang]{footmisc}
%\renewcommand{\footnotelayout}{\hspace{1mm}}
\renewcommand{\hangfootparindent}{1em}% Indentation for 2nd etc. paragraphs in footnotes which cosists of more than one paragraph
\renewcommand{\hangfootparskip}{3pt}% Vertical space between paragraphs in multiparagraph footnotes
\renewcommand{\footnotemargin}{0.00001pt}% Setting left margin; this is the smallest value I can get to have second etc. lines indented to footnote number; zero put indentation to some positive value, and negative values do not help actually
\renewcommand{\footnotelayout}{\hspace{1em}}% Here you can modify the spacing between the footnote number and the text of footnote; keep this value and \hangfootparindent value the same


%----------------------------------------------------------------------------------------
%   CAPTION AND FIGURES
%----------------------------------------------------------------------------------------
\usepackage[skip=6pt, font=small, justification=centering, labelfont=it, textfont=it]{caption}
\usepackage[labelformat=empty]{subcaption}
\DeclareCaptionSubType*{figure}
\renewcommand\thesubfigure{Rys. \thefigure\alph{subfigure}:}
%\renewcommand\thesubfigure{(Rys. \thefigure\alph{subfigure})}
\DeclareCaptionLabelFormat{opening}{#2}
\captionsetup[subfigure]{labelformat=opening}
%\renewcommand{\figurename}{Fig.}
%\usepackage[figurename=Fig.]{caption}

\usepackage{qrcode}
% \usepackage{pst-barcode}

\usepackage{lipsum}

% Rys.
% \DeclareCaptionSubType*{figure}
% \renewcommand\thesubfigure{(\alph{subfigure})}
% \DeclareCaptionLabelFormat{opening}{\thefigure#2}
% \captionsetup[subfigure]{labelformat=opening}

\usepackage{float}
\usepackage{placeins}
\usepackage{siunitx}
\sisetup{detect-family=true, detect-display-math = true}
%\sisetup{detect-weight=true, detect-family=true, detect-display-math = true}

\usepackage{tikz} % Required for drawing custom shapes
\usepackage{amsthm}
\usepackage{amsmath,amsfonts,amssymb} % For math equations, theorems, symbols, etc

\usepackage{ulem}
% \usepackage[euler]{textgreek}

% \usepackage[polish]{babel} % English language/hyphenation
% \usepackage[english]{babel} % English language/hyphenation

\usepackage[utf8]{inputenc}
\usepackage[autostyle]{csquotes}
\DeclareQuoteAlias{dutch}{polish}
\usepackage[T1]{fontenc}
\usepackage{babel}

% \usepackage[utf8]{inputenc} % Required for including letters with accents
% \usepackage{polski}
% \usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
% \usepackage[autostyle]{csquotes}
% \DeclareQuoteAlias{dutch}{polish}

\DeclareMathSymbol{,}{\mathpunct}{letters}{"3B}
\DeclareMathSymbol{.}{\mathord}{letters}{"3B}
\DeclareMathSymbol{\decimal}{\mathord}{letters}{"3A}

\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists
%\let\labelitemi\labelitemi
%\renewcommand\labelitemii{\textbullet}
%\renewcommand\labelitemii{\textperiodcentered}
\renewcommand\labelitemii{$\circ$}
\renewcommand\labelitemiii{\tiny$\blacksquare$}
%\renewcommand\labelitemiii{\LARGE$\cdot$}
%\newcommand\labelitemi{\textbullet}% bullet

%\Huge
%\huge
%\LARGE
%\Large
%\large
%\normalsize (default)
%\small
%\footnotesize
%\scriptsize
%\tiny

\usepackage{booktabs} % Required for nicer horizontal rules in tables
\usepackage{xcolor} % Required for specifying colors by name
% \usepackage{dirtytalk}
\usepackage{framed}
\usepackage[most]{tcolorbox}
\fboxsep=0mm%padding thickness
\fboxrule=1pt%border thickness
\input{colours.tex}

%----------------------------------------------------------------------------------------
%   FONTS
%----------------------------------------------------------------------------------------
\usepackage{avant} % Use the Avantgarde font for headings
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Sym­bol, Chancery and Com­puter Modern fonts
\usepackage{microtype} % Slightly tweak font spacing for aesthetics

\frenchspacing
\usepackage{parskip}

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------
\usepackage{csquotes}
\usepackage[style=alphabetic,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,autolang=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber,defernumbers=true]{biblatex}
\addbibresource{bibliography.bib} % BibTeX bibliography file
\defbibheading{bibempty}{}

\usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly
\usepackage{makeidx} % Required to make an index
\makeindex % Tells LaTeX to create the files required for indexing

%----------------------------------------------------------------------------------------
%   MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------
\usepackage{titletoc} % Required for manipulating the table of contents
\contentsmargin{0cm} % Removes the default margin

% Chapter text styling
\titlecontents{chapter}[1.25cm] % Indentation
{\addvspace{12pt}\large\sffamily\bfseries} % Spacing and font options for chapters
{\color{basecolour!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{basecolour}} % Chapter number
{\color{basecolour}}  
{\color{basecolour!60}\normalsize\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number

% Section text styling
\titlecontents{section}[1.25cm] % Indentation
{\addvspace{3pt}\sffamily\bfseries} % Spacing and font options for sections
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{\hfill\color{black}\thecontentspage} % Page number
[]

% Subsection text styling
\titlecontents{subsection}[1.25cm] % Indentation
{\addvspace{1pt}\sffamily\small} % Spacing and font options for subsections
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[]

% List of figures
\titlecontents{figure}[0em]
{\addvspace{-5pt}\sffamily}
{\thecontentslabel\hspace*{1em}}
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage}
[]

% List of tables
\titlecontents{table}[0em]
{\addvspace{-5pt}\sffamily}
{\thecontentslabel\hspace*{1em}}
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage}
[]

%----------------------------------------------------------------------------------------
%   PAGE HEADERS
%----------------------------------------------------------------------------------------
\usepackage{fancyhdr} % Required for header and footer configuration

%\newcommand*\small{%   
%\@setfontsize\small\@xpt\@xiipt 

\pagestyle{fancy}
%\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries\chaptername\ \thechapter.\ #1}{}} % Chapter text font settings
%\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}} % Section text font settings
\renewcommand{\chaptermark}[1]{\markboth{\large\bfseries\chaptername\ \thechapter.\ #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\small\thesection\hspace{5pt}#1 – https://kurs.forbot.pl/elektronika}{}} % Section text font settings
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Font setting for the page number in the header
\fancyhead[LO]{\rightmark} % Print the nearest section name on the left side of odd pages
\fancyhead[RE]{\leftmark} % Print the current chapter name on the right side of even pages
\renewcommand{\headrulewidth}{0.5pt} % Width of the rule under the header
\addtolength{\headheight}{2.5pt} % Increase the spacing around the header slightly
\renewcommand{\footrulewidth}{0pt} % Removes the rule in the footer
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} % Style for when a plain pagestyle is specified

% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}

%----------------------------------------------------------------------------------------
%   BOXES
%----------------------------------------------------------------------------------------
\input{boxes.tex}

%----------------------------------------------------------------------------------------
%   SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------
\makeatletter
\renewcommand{\@seccntformat}[1]{\textcolor{basecolour}{\csname the#1\endcsname}\hspace{0.5em}}%odsuniecie numeracji
%\renewcommand{\@seccntformat}[1]{\llap{\textcolor{basecolour}{\csname the#1\endcsname}\hspace{0.5em}}}%odsuniecie numeracji

\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}

\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}

\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}

\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}

%----------------------------------------------------------------------------------------
%   CHAPTER HEADINGS
%----------------------------------------------------------------------------------------
\newif\ifusechapterimage
\usechapterimagetrue
\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\ifusechapterimage\renewcommand{\thechapterimage}{#1}\fi}%
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-7cm) node [line width=2pt,rounded corners=0pt,draw=basecolour,fill=white,fill opacity=0.9,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-7cm) node {\huge\sffamily\bfseries\color{black}\thechapter. #1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-7cm) node [line width=2pt,rounded corners=0pt,draw=basecolour,fill=white,fill opacity=0.9,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-7cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{180\p@}}}

%-------------------------------------------
\def\@makeschapterhead#1{%
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-7cm) node [line width=2pt,rounded corners=0pt,draw=basecolour,fill=white,fill opacity=0.9,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-7cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\par\vspace*{180\p@}}
\makeatother

%----------------------------------------------------------------------------------------
%   HYPERLINKS IN THE DOCUMENTS
%----------------------------------------------------------------------------------------
\usepackage{hyperref}
\hypersetup{hidelinks,colorlinks=false,breaklinks=true,urlcolor= basecolour,bookmarksopen=false,pdftitle={Title},pdfauthor={Author}}
\usepackage{bookmark}
\bookmarksetup{
open,
numbered,
addtohook={%
\ifnum\bookmarkget{level}=0 % chapter
\bookmarksetup{bold}%
\fi
\ifnum\bookmarkget{level}=-1 % part
\bookmarksetup{color=basecolour,bold}%
\fi}
}


%----------------------------------------------------------------------------------------
%   QUIZ
%----------------------------------------------------------------------------------------
%\alph*$\square$ 

% \newlist{questionlist}{enumerate}{2}
\usepackage{multicol}
\newlist{quizlist}{enumerate}{2}
\setlist[quizlist]{label=\textbf{$\square$ \alph*)},itemsep=4pt,topsep=4pt}
% \usepackage{pifont}
% \newcommand{\cmark}{\ding{51}}%
% \newcommand{\xmark}{\ding{55}}%
% \newcommand{\done}{\rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}}%
% \hspace{-2.5pt}}
% \newcommand{\wontfix}{\rlap{$\square$}{\large\hspace{1pt}\xmark}}

Edit:

Solution to above problem is fine, thank you! But there seems to be another problem. My command to add 2 images in a row works fine, but probably it's also written not very well, so if possible please help me fix it. I dont really know how to skil using float while removing subfigures.

\newcommand{\doubleimage}[6]{
\begin{figure}[ht]
\centering
\begin{subfigure}[t]{0.48\textwidth}
\fcolorbox{frameColor}{white}{\includegraphics[width=\textwidth]{#1}}%
\caption{#3}
\label{#5}
\end{subfigure}
\hspace{\fill}
% \qquad
\begin{subfigure}[t]{0.48\textwidth}
\fcolorbox{frameColor}{white}{\includegraphics[width=\textwidth]{#2}}%
\caption{#4}
\label{#6}
\end{subfigure}
\end{figure}
\FloatBarrier
}

And output looks like in the image and shood stay like this. 2 images aligned with left and right with small gap between with 2 subtitles not floating between paragraphs.

2 images side by side

I also have modified way of displaying subtitles, hope it will not break:

\renewcommand\thesubfigure{Rys. \thefigure\alph{subfigure}:}
5
  • 3
    If you don't want the figures to move, don't use float. You can place the images directly, without the figure-environment. Captions can be added with \captionof. Also: please provide a compilable minimal working example (MWE)
    – DG'
    May 21, 2020 at 9:33
  • 1
    using \FloatBarrier immediately after a figure is a really strange thing to do. The intention of that command is to put it at a fixed position (say a section heading) to stop floating objects going past that point, and if necessary forcing a page break to flush them out. Specifying that something can float by surrounding it in figure then immediately using \clearpage to force a page break and stop it floating is very contradictory so it isn't clear what behaviour you intend. May 21, 2020 at 9:39
  • As I mentioned I'm not good, and doing this as trial and error process while reading examples. I noticed that without floatbarrier images are placed not in fixed position. I would like to place them in place where I write command - exactly after one paragraph and before another. I'l check what is MWE later, thank you :)
    – Gienek
    May 21, 2020 at 9:47
  • 1
    The only thing \begin{figure} does is take the content out of the document flow and allow it to be moved. So if your images are part of the paragraph you should just use \includegraphics not figure May 21, 2020 at 9:51
  • 1
    See here for strategies to get float exactly here texfaq.org/FAQ-figurehere May 21, 2020 at 9:53

1 Answer 1

0

You could try without the figure-environment:

\newcommand{\image}[4][40mm]{
    \centering%
    \fcolorbox{frameColor}{white}{\includegraphics[width=\textwidth, height = #1, keepaspectratio]{#2}}
    \captionof{figure}{#3}%
    \label{#4}
}
2
  • Wow great! That exacly what I wanted, one thing I changed was \begin{center}, becouse \center changed all paragraphs. But I have another question. I have second command which places 2 images side by side with small gap between. It uses subfigures. I edited above question, and code is at the end. Could you help me
    – Gienek
    May 22, 2020 at 6:37
  • It's better to ask a new question for each issue instead of editing the old ones.
    – DG'
    May 22, 2020 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .