Add \par
after #2
. (No, I don't know why this works.)
EDIT: Or simply omit the additional set of braces in the macro definition.
\documentclass{article}
\newcommand*\defineA[2]{%
\marginpar{{\sffamily\footnotesize\textbf{#1}: #2}}}
\newcommand*\defineB[2]{%
\marginpar{{\sffamily\footnotesize\textbf{#1}: #2\par}}}
\newcommand*\defineC[2]{%
\marginpar{\sffamily\footnotesize\textbf{#1}: #2}}
\usepackage{blindtext}
\begin{document}
Some text.\defineA{foo}{\blindtext} \blindtext
\clearpage
Some text.\defineB{foo}{\blindtext} \blindtext
\clearpage
Some text.\defineC{foo}{\blindtext} \blindtext
\end{document}
There are not random results but inconsistent settings. Please use the option showframe
in the package geometry
and see the log file to understand what happen with your settings.
Take into account that top margin in Lyx should be 15 mm
plus headheight
plus headsep
and that header text should be enough small to fit in the headheight
, otherwise LaTeX will change his setting trying to do the best.
In the same way, bottom margin should be 15 mm
plus the footskip
, but the footer text must fit within the foot skip.
Taking this into account, you can already fix without problems the margins using the normal menu of LyX (Documents>Settings...>Page Margins), but there are nothing wrong checking "Defaults Margins" box and using the package geometry
directly in Documents>Settings...>LaTeX preamble. This allow you to use options of geometry
that LyX cannot manage, or use dynamic dimensions, so the margins are calculated correctly independently of the default font size:
\documentclass{article}
\usepackage[paperheight=16cm,paperwidth=14cm,showframe]{geometry}
\geometry{
lmargin=15mm,
rmargin=15mm,
tmargin=\dimexpr15mm+1.5\baselineskip,
bmargin=\dimexpr15mm+1.5\baselineskip,,
headheight=\baselineskip,
headsep=.5\baselineskip,
footskip=1.5\baselineskip}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\section{Testing margins}
\lipsum*[1]\footnote{A foonote}
\lipsum*[2]\footnote{A foonote}
\lipsum*[3-5]
\end{document}
Some like \chead{\Huge A}
just at the end of the preamble will ruin this layout, but LaTeX warn you in the .log
file:
Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 30.0pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.
Also, as you can see in this MWE, the footnotes are not a problem at all, since they are included in the text area, not in the margins.
On the other hand, for a 12pt
article the default font size in footnotes (\footnotesize) is 10pt
, so you must use a \scriptsize
. See What point (pt) font size are \Large etc.? and Set font size for footnotes.
Best Answer
Add
heightrounded
to your\usepackage{geometry}
. It basically modifies the bottom margin automatically.