GeneralWhy 2pages with same code are not identical ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
pcouderc
Posts: 2
Joined: Sat Jun 12, 2021 10:57 am

Why 2pages with same code are not identical ?

Post by pcouderc »

I have a document (MWE) with 4 pages.
Page 1 and page 3 are expected to be identical but some space is inserted in page 3 after the 1rst line truncating the image. Why ?

Code below and too https://www.couderc.eu/download/ttt.tex
Compiled with lualatex : my result https://www.couderc.eu/download/ttt.pdf
The image (not in public domain (: ) is here : https://www.couderc.eu/download/IMG_0058_cadree.jpg

Thanks for any help.
PC

Latex code:

Code: Select all

\documentclass[10pt]{article} % use larger type; default would be 10pt
\usepackage[letterpaper,landscape,margin=5mm]{geometry} 
\usepackage[latin,french]{babel}
\selectlanguage{french}
\usepackage{mwe}
\usepackage{graphicx}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{multicol}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\usepackage{tabto}
\usepackage{supertabular}
\color{white}
\renewcommand{\seriesdefault}{bx}
\pagecolor{black}
\setlength{\columnsep}{1cm}
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{center}
\fontsize{30}{40}\selectfont
        Un petit titre\\[1cm]
\end{center}
\begin{multicols}{2}[]
\includegraphics[scale=0.14]{IMG_0058_cadree.jpg}
\begin{center}
\fontsize{60}{72}\selectfont
\vspace*{\stretch{1}}
Une petite citation
\vspace*{\stretch{1}}
\end{center}
\end{multicols}
\newpage
\fontsize{60}{72}\selectfont
\begin{center}
Un petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit petit texte.\\
\end{center}
\newpage
\null
\newpage
\begin{center}
\fontsize{30}{40}\selectfont
        Un petit titre\\[1cm]
\end{center}
\begin{multicols}{2}[]
\includegraphics[scale=0.14]{IMG_0058_cadree.jpg}
\begin{center}
\fontsize{60}{72}\selectfont
\vspace*{\stretch{1}}
Une petite citation
\vspace*{\stretch{1}}
\end{center}
\end{multicols}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Why 2pages with same code are not identical ?

Post by Bartman »

If you adjust the preamble of your example as follows

Code: Select all

\usepackage[demo]{graphicx}
\usepackage{mwe}% loads graphicx
the readers of your topic can test it without having the images. Furthermore, the order in which the packages are loaded prevents an error message due to an option clash.

Now a hint to your actual problem: You use the commands to set the font size almost always in an environment, only once not.

BTW:

The font size you specify when loading the class is the default.

The command \selectlanguage{french} is not needed because the language of the document is already set by the last option when loading the babel package.

Maybe it may not apply to your case, but in a conventional document you should never remove only the paragraph indent, otherwise it remains unclear how the paragraphs are marked. For a standard class, the use of the parskip package would then be preferable.
pcouderc
Posts: 2
Joined: Sat Jun 12, 2021 10:57 am

Why 2pages with same code are not identical ?

Post by pcouderc »

Thank you for these fine comments :
1- Yes, by adding a simple :
\fontsize{10}{12}\selectfont
at the beginning of last page, the problem is corrected. But I do not understand why !!!

2- Thank you for mwe. I had tried it but did renounce to read the full documentation, when your solution is so simple...

3- And thank you for default language in babel...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Why 2pages with same code are not identical ?

Post by Stefan Kottwitz »

In line 34, the commands \fontsize{60}{72}\selectfont are not within an environment, so they are global.

The effect is:
  • On the first page, you have the default (small) font size.
  • On the second page, you set the font to the big size (60/72), valid from now on.
  • Page 3 then has that big font size too.
That's basically the difference. You have exactly the same code for the page, but the current font size is different. This has a noticable effect: a center environment has space around it, depending on the font size around it. So your centered line Un petit titre takes more space on the third page.

That's a reason why font size commands should be within a \begin{...} ... \end{...} environment or within a { ... } group, so their effect is locally, restricted to that environment or group. That's what you did right, when you had the \fontsize command in the center environment.

Btw. instead of adding \fontsize{10}{12}\selectfont on the last page, you could also "reset" the font size by writing \normalsize.But the better thing would be to see how to put that \fontsize command in an environment or a { ... } group.

Another thing: \begin{center} ... \end{center} is for displaying centered text within surrounding text, so it comes with space before and after. A title would not need that space (before) so you could consider writing for example {\centering Un petit titre\\[1cm]}. Also here, the effect of \centering is limited by the braces. Looks like a center environment without the space before and after.

Stefan
LaTeX.org admin
Post Reply