1

I have a problem with loading color packages. I have started my document some time a go and I have around 90 pages. Just now I wanted to add some code listings with colors so I loaded color package. My whole document then got messed around as the spaces between images got changed and the images started traveling to the next page... Is there a way to forbid those color packages like color or xcolor to change the spacing at all? Here is my template:

%% Clear sans, courier

% Klasa:
\documentclass[12pt]{mwart}

% Kodowanie:
\usepackage[utf8]{inputenc}

% odstep w listach
\usepackage[titles]{tocloft}
\addtolength{\cftfignumwidth}{10pt}

% Czcionki:
\usepackage[sfdefault]{ClearSans} %% option 'sfdefault' activates Clear Sans as the default text font
\usepackage[T1]{fontenc}
\usepackage{courier}
\usepackage[T1]{polski}

% Znak euro
\usepackage[official]{eurosym}

% Geometria i style
%\usepackage{showframe} % debug
\usepackage{geometry}
\geometry{a4paper,twoside=true,top=20mm,bottom=30mm,inner=35mm,outer=20mm}
\pagestyle{plain}
\usepackage{float}
\usepackage{afterpage}

% Grafika
\usepackage{graphicx}
\usepackage{epstopdf}

% matma
\usepackage{amssymb,amsmath}

% theoremy
\usepackage{amsthm}

% Stopnie
\usepackage{gensymb}

% Opisy
\usepackage{caption}
\captionsetup[table]{singlelinecheck=off}

% Tabele
\usepackage{float}
\floatstyle{plaintop}
\restylefloat{table}
\usepackage{array}
\usepackage{makecell}
%\usepackage{color}

% Footnoty
\usepackage{footnote}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command

% kody
\usepackage{lipsum}
\usepackage{listings}

% Numerowanie obiektow wedlug rozdzialow
\usepackage{chngcntr}
\AtBeginDocument{\counterwithin{lstlisting}{section}}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\numberwithin{equation}{section}


% Linki
\usepackage{url}
\usepackage{fancyref}

% Listy
\usepackage[ampersand]{easylist}
\ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=-- ,
Style2*=$\bullet$ ,Style3*=$\circ$ ,Style4*=\tiny$\blacksquare$ )

% Dane:
\title{Uniwersalny inteligentny sterownik silników do zastosowań przemysłowych}
\author{Łukasz Przeniosło}

% Zmienne srodowiskowe:
\newcommand{\paperTitlePl}{UNIWERSALNY INTELIGENTNY STEROWNIK SILNIKÓW DO ZASTOSOWAŃ PRZEMYSŁOWYCH}
\newcommand{\paperTitleEn}{UNIVERSAL INTELIGENT MOTOR DRIVER FOR INDUSTRIAL APPLICATIONS}
\newcommand{\topicChooseDate}{01.08.2015 r.}
\newcommand{\topicAcceptationDate}{01.06.2016 r.}
\newcommand{\tocLessLeft}[1]{\textsc{\textbf{\large \flushleft{#1}}} \vspace{3mm} \\ \indent }
\newcommand{\tocLessLeftNorm}[1]{\textsc{\textbf{\normalsize \flushleft{#1}}} \vspace{0mm} \\ \indent }
\newcommand{\tocLessCenter}[1]{\textsc{\textbf{\large \centerline{#1}}} \vspace{3mm} \\ \indent }
\newcommand{\insertImg}[3]{%
\begin{figure}[h]
    \centering
    \includegraphics[height=50mm]{#1}
    \caption{#2} \flushleft{Źródło: Na podstawie \cite{#3}}
    \label{#1}
\end{figure}
}
\newcommand{\insertImgSetSize}[4]{%
\begin{figure}[h]
    \centering
    \includegraphics[height=#2mm]{#1}
    \caption{#3} \flushleft{Źródło: Na podstawie \cite{#4}}
    \label{#1}
\end{figure}
}
\newcommand{\insertTab}[5]{%
\begin{savenotes}
    \begin{table}[h]
        \flushleft{Źródło: Na podstawie \cite{#4}} \\
        \vspace{2mm}
        \centering
        \begin{tabular}{#1} 
        #2
        \end{tabular}
        \caption{#3}  
        \label{#5}
        \floatstyle{plaintop}
    \end{table}
\end{savenotes}
}

% Zmienic jesli jednak Engineering -.- ...
\newcommand{\firma}{{Mechatronic Systems}}

% twierdzenia
\newtheorem{defn}{Definicja}[section]

% Indeksowanie w pdfie wyjsciowym
\usepackage{hyperref}

% Naprawienie referencji do figur i tabel
\renewcommand{\theHfigure}{figure.section.thesection.\thefigure}

% START:
\begin{document}

some text text text

\insertImgSetSize{example-image-a}
    {40}
    {1st image}
    {badcite}

some text text text

\insertImgSetSize{example-image-a}
    {50}
    {1st image}
    {badcite}

some text text text

\insertImgSetSize{example-image-a}
    {60}
    {1st image}
    {badcite}

some text text text

\insertImgSetSize{example-image-a}
    {50}
    {1st image}
    {badcite}



\end{document}

Edit: I have updated the example, it is ready to be pasted and run. Please notice how color package is commented out in line 53. Compile the code and see the document. Then uncomment the color package and compile, you will see the spacing increase. Is there a way to disable this spacing increase?

16
  • ...I wonder how we can recreate this issue locally... do you mind helping us do that so we can see what you mean by "the addition of color moved things around... messed it up."? We would need something that replicates the problem.
    – Werner
    Commented Jun 22, 2016 at 20:11
  • Sorry, it happens after I add \usepackage{color} or \usepackage{xcolor} Commented Jun 22, 2016 at 20:12
  • That's fine... so what's in theorems.tex? Without it, we can't really compile your document and see what the effect of the changes are.
    – Werner
    Commented Jun 22, 2016 at 20:13
  • Sorry again... All that file contains is one line: \newtheorem{defn}{Definicja}[section] Commented Jun 22, 2016 at 20:14
  • 1
    Not really, as documented in the color package documentation it can affect spacing in some cases. unrelated but {\large \flushleft{#1}}} will not make things go flush left, unless #1 ends in a blank line, \centerline shouldn't really be used in latex, \flushleft{Źródło: Na podstawie \cite{#4}} is wrong \flushleft does not take an argument it affects the rest of the current group and \afterpage{\null \thispagestyle{empty} \newpage} is i assume intended to do \cleardoublepage but using a pagestye empty, there are far safer ways to do that! Commented Jun 22, 2016 at 20:20

1 Answer 1

1

You're using wrongly \flushleft

\newcommand{\insertImg}[3]{%
\begin{figure}[h]
    \centering
    \includegraphics[height=50mm]{#1}
    \caption{#2}\label{#1}
    \raggedright Źródło: Na podstawie \cite{#3}
\end{figure}
}
\newcommand{\insertImgSetSize}[4]{%
\begin{figure}[h]
    \centering
    \includegraphics[height=#2mm]{#1}
    \caption{#3}\label{#1}
    \raggedright Źródło: Na podstawie \cite{#4}
\end{figure}
}
\newcommand{\insertTab}[5]{%
\begin{savenotes}
    \begin{table}[h]
        \raggedright Źródło: Na podstawie \cite{#4}\\
        \vspace{2mm}
        \centering
        \begin{tabular}{#1} 
        #2
        \end{tabular}
        \caption{#3}  
        \label{#5}
        \floatstyle{plaintop}
    \end{table}
\end{savenotes}
}
2
  • Thank you... Can I ask what was really wrong with flushleft? Commented Jun 24, 2016 at 21:24
  • 1
    @ŁukaszPrzeniosło \flushleft exists only because of the flushleft environment. It should never be used in the body of the document, but only, with care, in the definition of other environments (not macros), in the “begin” part. In this case it should always be followed by \endflushleft in the “end” part. The corresponding declaration is \raggedright.
    – egreg
    Commented Jun 24, 2016 at 21:29

You must log in to answer this question.

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