GeneralInconsistent hfill when using input

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kpedro88
Posts: 6
Joined: Wed Aug 27, 2014 7:47 pm

Inconsistent hfill when using input

Post by kpedro88 »

I have encountered some strange behavior from \hfill when using \input for a section of my document.

A minimal working example is attached. doc1 shows the desired behavior without the use of \input. doc2 shows the observed behavior when including sec1 using \input: the \hfill on the last line is smaller than the normal \hfill, so the subsequent text is out of alignment with the text on the previous lines.

Any help solving this problem would be appreciated.
Attachments
doc.zip
(37.03 KiB) Downloaded 310 times
Last edited by cgnieder on Thu Aug 28, 2014 9:10 am, edited 2 times in total.

Recommended reading 2024:

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

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Inconsistent hfill when using input

Post by cgnieder »

Hi kpedro88,

Welcome to the LaTeX community!

Would you mind posting a Infominimal working example here? I for my part am always quite reluctant to download zip archives... besides it makes me suspect that the example files are not really minimal (which may very well be uncalled-for...)

Best
site moderator & package author
kpedro88
Posts: 6
Joined: Wed Aug 27, 2014 7:47 pm

Re: Inconsistent hfill when using input

Post by kpedro88 »

The working example contains 5 files, while the attachment upload limit is 4. The five files are as follows:
doc1.tex
doc1.pdf
doc2.tex
sec1.tex
doc2.pdf

You can now find these on my webspace:
http://kjplanet.com/input-bug/
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Inconsistent hfill when using input

Post by Johannes_B »

Please follow the link Clemens posted, where you can read how to prepare a minimal working example (which only consists of one file). You can add your output and still won't reach the upload maximum. ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kpedro88
Posts: 6
Joined: Wed Aug 27, 2014 7:47 pm

Inconsistent hfill when using input

Post by kpedro88 »

The error involves the use of \input, so a complete minimal working example consisting of one file is obviously impossible.

I have combined two of the files, so the desired and the buggy behavior are shown together. The new example is attached (including both the source and compiled PDF so the behavior can be easily observed).
Attachments
sec1.tex
(106 Bytes) Downloaded 368 times
doc1.tex
(181 Bytes) Downloaded 314 times
doc1.pdf
(20.89 KiB) Downloaded 355 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Inconsistent hfill when using input

Post by Johannes_B »

You can; using filecontents ;-)

Code: Select all

\begin{filecontents}{\jobname doc.tex}
\section{inputted file}
blah \hfill December 2013\\
blah \hfill December 2012\\
blah \hfill December 2011% <- This is important
\end{filecontents}
\documentclass{article}
\begin{document}
\section{Section 1}
blah \hfill December 2013\\
blah \hfill December 2012\\
blah \hfill December 2011
\input{\jobname doc}
\end{document}
You need to be aware of the last line of the input document. The Line end is giving you a space. Comment this out using a percent sign (%).
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kpedro88
Posts: 6
Joined: Wed Aug 27, 2014 7:47 pm

Re: Inconsistent hfill when using input

Post by kpedro88 »

Ah, that does it. Thanks!
Post Reply