0

I got a document containing multiple different exercises. Each exercise is placed in a minipage environment and included in the main document. For the first page, there is a big space between the section and the starting of the first minipage. In addition, the first minipage is indented to the left (yes I already tried to use noindent, but it doesn't make a difference). Each exercise is defined like this:

\begin{minipage}[t]{\textwidth}
exercise content here 
\end{minipage}
\vspace{0.5cm} %to create some space between exercises

Then the main file looks like this:

\section{Name of the section}
\subimport{folder}{ex1}
\subimport{folder}{ex2}
...

So the 2 problems I'm dealing with are:

  1. The space between the section and the first minipage is really big without defining space (space at the bottom wouldn't matter, for the following pages it's all right).
  2. The first minipage is indented to the left. I already tried no indent and similar commands.

Thank you for your time and help

Edit since the spacing problem is already solved, here a MWE for the indent problem:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\begin{document}
\section{This is a section title}
\begin{minipage}{\textwidth}
\textbf{Exercise}\\
Some text
\end{minipage}
\vspace{0.5cm}

\begin{minipage}{\textwidth}
\textbf{Exercise}\\
Some text
\end{minipage}
\vspace{0.5cm}

\begin{minipage}{\textwidth}
\textbf{Exercise}\\
Some tex
\end{minipage}
\vspace{0.5cm}

\begin{minipage}{\textwidth}
\textbf{Exercise}\\
Some text
\end{minipage}
\vspace{0.5cm}

\end{document}

The goal is, that all minipages are aligned the same way.

3
  • Welcome to TeX.SE. The first thing I can think of checking is if this still happens when you skip the importing step and instead have everything in one file. If it still happens, then that would be an easier way to post what is happening instead of asking us to create several files that will probably show the problem you're talking about. See tex.meta.stackexchange.com/q/228/107497
    – Teepeemm
    May 31, 2020 at 23:46
  • You say space at the bottom is no problem, so you recognize that bad page breaks are inevitable, but did you tell that to LaTeX by declaring \raggedbottom? Jun 1, 2020 at 0:26
  • Oh I didn't know that so using \raggedbottom solved the space between the first minipage and the section. Now the only problem is, that the second minipage is indented.
    – CrownUpKid
    Jun 1, 2020 at 0:37

1 Answer 1

1

As the first problem was solved in the comments, this answer only deal with to the second point.

The first minipage is not indented in any sense. The others are indented to the right. Change each minipage by "Foo." and you will see the same alignment:

\documentclass{article}
\begin{document}
\section{This is a section title}
Foo. 

Foo. 

Foo. 

Foo. 
\end{document}

What you have here is four paragraphs, where each paragraph it is only a box instead of many words and sentences, but that no change the indentation rules. And there are not indentation in the first paragraph after a section (in default English style), as it is always clear where it start.

The solution is add \noindent before of each minipage except to the first, or set \parindent to 0pt. That is, using still "Foo" in representation of the minipages:

\documentclass{article}
\begin{document}
\section{This is a section title}
Foo. 

\noindent Foo. 

\noindent Foo. 

\noindent Foo. 
\end{document}

...or ...

\documentclass{article}
\setlength{\parindent}{0pt}
\begin{document}
\section{This is a section title}
Foo. 

Foo. 

Foo. 

Foo. 
\end{document}

Notes:

  1. Inside the minipages, the \parindent is already 0pt and setting \parindent outside the minipages will not change that.
  2. Instead of \vspace{0.5cm}plus a blank line each time, it could be better set also\parskipin the preamble (e.g.,\setlength{\parindent}{0.5cm}`). Easier and the content is less obfusctaed by the code.
  3. Probably you are using minipages to avoid the window "Exercise" headers or orphan lines in the next page, but with or without \raggedbottom, some awful gaps will be unavoidable at some place using minipages, specially if the excercises are not very short. Probably will be better not use minipages at all, but simply \subsection*{Exercise} Some text and allow some page breaks within the long exercises.
12
  • Avoiding minipage is good. I suggest putting \filbreak between the exercises, rather than wrapping them in minipage. Jun 1, 2020 at 5:30
  • @DonaldArseneau A think that a section heading have less penalty to page break that \filbreak, so using \subsection* or \subsubsection* instead of \textbf, \filbreak will be not necessary.
    – Fran
    Jun 1, 2020 at 5:43
  • They are quite different, typically, because \raggedbottom changes nothing about the breaking of pages, only the layout after the break is chosen. The penalties in \section are usually quite ineffective against the badness of page layout. They will not ensure each exercise stays as a unit. A neat trick is to add more flexibility to the page: \addtolength{\topskip}{0pt plus0.5\textheight} will let \section keep exercises in one piece. Jun 1, 2020 at 6:38
  • @DonaldArseneau I mean that according Frank Mittelbach here the header will have priority as break point (penalty of -300 versus only -200 in \filbreak). Of course, this not avoid breaks in the middle of the exercise, but not after the header and encourage it before the header. This should be enough in many cases using also a reasonable glue in \parskip, or using the parskip package. IMHO is better deal with some problem of widow/orphan lines that destroy the consistency of the document layout with gaps everywhere.
    – Fran
    Jun 1, 2020 at 7:09
  • Since avoiding breaks in the middle of an exercise is the key point of minipage, so the intent is to replicate that. As I already explained, the lower penalty does not take precedence, unless it is combined with a very large flexibility on the page (or if it happens to come very close to the bottom of the page). Jun 1, 2020 at 8:27

You must log in to answer this question.

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