Document ClassesHow to ask \input{} and \include{} questions?

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How to ask \input{} and \include{} questions?

Post by LaTexLearner »

In my last thread, I decided to figure out how to learn how to structure a fairly large project first, then start entering content. But now that I'm actually trying to collect the stuff I do have, it's not compiling the way I want it to and I'm not even sure which code to include here because my preamble is so long. (There were no compiling problems with the individual file before I started preparing it for the book class.)

An issue right now is why the page announcing Chapter 1 looked just fine, but the page announcing the 2nd chapter is just weird.

Image

How should I begin investigating this? I.e. What info could I post here?

P.S. I created tiny practice files so I could get used to using the book class and it seems fairly straightforward. I did not have this problem with my own practice files.

Recommended reading 2024:

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

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

LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How to ask \input{} and \include{} questions?

Post by LaTexLearner »

Another totally weird output from the same file.

The spacing in an \enumerate list is just vastly excessive. I have no idea why it looks like this. In the document's next page (not posted here) there is an \itemize list that looks just fine.

Image
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How to ask \input{} and \include{} questions?

Post by Stefan Kottwitz »

The book class balances the page content, so that they have the same height, by default. So text may be stretched. It's good for text books, in your case maybe not optimal.

You could turn it off by adding \raggedbottom to your document preamble.

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to ask \input{} and \include{} questions?

Post by Johannes_B »

The question of how to investigate is answered very easily: Just as usual, use the techniques described in How to create a minimal working example. Input really just inputs a file as if it would have been in the very same file. \include does a bit more and you should be aware of the difference.

How to ask questions on the forum that rely on an extra file? The LaTeX environment {filecontents} is great here. All the code can stay in one code block and you can use the online editor to see just the same as all other users here. We all have the same output to work on.

By the way, is there any need for using the book class? Why did you change? Maybe report is a good alternative.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How to ask \input{} and \include{} questions?

Post by LaTexLearner »

Johannes_B wrote:... By the way, is there any need for using the book class? Why did you change? Maybe report is a good alternative.
Two main reasons mentioned here.
  1. \frontmatter, \mainmatter, \backmatter
  2. the differences in margins, headers, and footers for the left- and right-side pages
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How to ask \input{} and \include{} questions?

Post by LaTexLearner »

Stefan_K wrote:The book class balances the page content, so that they have the same height, by default. So text may be stretched. It's good for text books, in your case maybe not optimal.

You could turn it off by adding \raggedbottom to your document preamble.

Stefan
Yes, that does sound like a feature that I don't need.

Where in the preamble would \raggedbottom go or does it not matter?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to ask \input{} and \include{} questions?

Post by Johannes_B »

LaTexLearner wrote:Yes, that does sound like a feature that I don't need.

Where in the preamble would \raggedbottom go or does it not matter?
It doesn't matter. But printed out, it might look weird that certain pages don't have the same text height (at least it seems like it).

The mainmatter stuff is only available with book, that is true. Margins and headers/footers can easily be customized using packages geometry and scrlayer-scrpage (among others).
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How to ask \input{} and \include{} questions?

Post by LaTexLearner »

Johannes_B wrote:... Input really just inputs a file as if it would have been in the very same file. \include does a bit more and you should be aware of the difference...
Stefan_k posted this link and it mentioned that if I am only want to print part of the file, \include will track all the page numbers and referencing of all the documents. Since I need to print frequently to make sure the pages are usable, \include seems to be better match than \input.

Or are there other differences I'm not aware of?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How to ask \input{} and \include{} questions?

Post by Stefan Kottwitz »

I would place \raggedbottom either directly after or before \begin{document}, so it works from the first page on, but doesn't get affected by any package since all are loaded before.

Back to the original question: yes, \include is perfect for chapters, \input for smaller things (no additional page break at the beginning), and \input for preamble parts, if you want to split it (packages, own macros).

But how to ask questions with such commands?
  • If the question is about things which are not related to the inclusion, such as math or TikZ or headers etc., then try to avoid \include / \input for reader convenience. Put the issue thingy from the included file into the main document for the minimal example. You know, serve a problem on a silver platter, then a quick help and solution is nearly guaranteed.
  • If the problem has something to do with the inclusion, such as "page break doesn't work for included file", "\ref doesn't work with \include", then we need the \include / \input code with main file and sub file. But also as minimal as possible (again the silver platter spoon-feeding thing for best result). Small codes should be posted as code blocks (one for each file), longer codes can be posted as attachment.
Don't worry if you don't manage to minimize for best presentation, we would also help if you post longer files as attachment. The most important is, to have all related code and additions (such as images) at hand, like as attachment, to verify a problem. A difficult or not good question & code presentation may be hard to understand and perhaps won't get an answer, even if we try (also because of limited time), but well presented questions with complete but minimal code will always be tested and most of the time answered. We like to solve problems.

Stefan
LaTeX.org admin
Post Reply