3

I am trying to put a numbering page inside the main text. The problem is that I am using margin notes, and want to "create" a space between the beginning of the margin notes space and the body of the text to put the line's numbers, because now, the Margin notes overlaps the number of lines.

Here my code:

\documentclass[14pt]{book}
\usepackage[a4paper, nofoot,includeall,left=0.5cm, right=0cm, top=0cm,bottom=0.5cm,marginparsep=0pt,headsep=0pt,marginparwidth=170pt,headheight=35pt]{geometry}
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\pagestyle{fancy}% Change page style to fancy
\fancyhf{}% Clear header/footer
\fancyhead[C]{Header}
\usepackage{lipsum}
\usepackage{marginnote}
 \usepackage[right]{lineno}

\newcounter{mynote}% a new counter for use in margin notes

\newcommand{\mynote}[2][0]{% a simple margin note
    \refstepcounter{mynote}% step counter
    \mbox{\textsuperscript{\themynote}}% the number (superscript) in text
    \marginnote{\mbox{\textsuperscript{\themynote}}#2}[#1\baselineskip]% the note
}

\usepackage{titlesec}

\usepackage{fontspec}
%\defaultfontfeatures{Ligatures=TeX}
%\usepackage{showframe}
\usepackage{hyperref}
%\usepackage{longtable}
\usepackage{textcomp}




\setmainfont{KadmosU}
\begin{document}
\linenumbers
 Lorem ipsum dolor sit amet\mynote{here one note}, consectetur adipiscing elit. Nulla a felis a nulla aliquet varius. Fusce eget pretium lacus. Nulla\mynote{here another} leo massa, efficitur cursus dictum a, rutrum non ipsum. Proin condimentum, odio et dictum varius, ante sem mattis est, vitae congue odio metus nec nibh. Integer euismod viverra condimentum. Aliquam erat\mynote{other} volutpat. Donec ut sapien fringilla, convallis sem quis, malesuada metus. Quisque mollis iaculis erat a egestas. Nullam lacinia tortor ac vehicula pellentesque. Aliquam sollicitudin viverra ultricies. Sed tincidunt ex dolor, ac malesuada metus commodo id. Cras porttitor in dolor a dapibus. Proin sagittis velit in ligula consequat, at interdum erat rhoncus.

Suspendisse ac viverra augue. Quisque posuere vehicula elementum. Suspendisse potenti. Etiam ac posuere arcu. Nulla convallis magna vel massa fringilla, ut rutrum orci lobortis. Pellentesque mi nibh, rutrum at pulvinar a, scelerisque sed velit. In hac habitasse platea dictumst. Etiam rhoncus dolor lacus. Nam ac lacus id mauris vehicula lobortis quis vel arcu. Nulla vestibulum, turpis quis posuere mattis, diam arcu dictum magna, non laoreet mauris purus non purus. Aliquam eu lacus sit amet velit auctor vulputate. Nulla non sapien blandit, mattis metus in, congue ante. Nam interdum, nunc dignissim fringilla dictum, libero tortor feugiat leo, nec elementum purus arcu sit amet justo. 


\end{document}

Here the problem! Margin notes overlaps the numbers.

1
  • your title asks about page numbers which do not seem to be involved, did you mean to ask about line numbers? Commented Apr 24, 2018 at 20:38

1 Answer 1

3

you can change the internal margins in your marginpar to avoid the line numbers, but the geometry settings you had had no right margin so on the second page the line numbers were off page.

enter image description here

\documentclass[10pt]{book}
%\usepackage[a4paper, nofoot,includeall,left=0.5cm, right=2cm, top=0cm,bottom=0.5cm,marginparsep=0pt,headsep=0pt,marginparwidth=170pt,headheight=35pt]{geometry}
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
\pagestyle{fancy}% Change page style to fancy
\fancyhf{}% Clear header/footer
\fancyhead[C]{Header}
\usepackage{lipsum}
\usepackage{marginnote}
 \usepackage[right]{lineno}

\newcounter{mynote}% a new counter for use in margin notes

\newcommand{\mynote}[2][0]{% a simple margin note
    \refstepcounter{mynote}% step counter
    \mbox{\textsuperscript{\themynote}}% the number (superscript) in text
    \marginnote{\mbox{\textsuperscript{\themynote}}#2}[#1\baselineskip]% the note
}



\renewcommand*{\raggedleftmarginnote}{\raggedleft\addtolength\hsize{-1cm}}
\renewcommand*{\raggedrightmarginnote}{\raggedright\setlength\leftskip{1cm}}


\usepackage{titlesec}

\usepackage{fontspec}
%\defaultfontfeatures{Ligatures=TeX}
%\usepackage{showframe}
\usepackage{hyperref}
%\usepackage{longtable}
\usepackage{textcomp}




%\setmainfont{KadmosU}
\begin{document}
\linenumbers
 Lorem ipsum dolor sit amet\mynote{here one note}, consectetur adipiscing elit. Nulla a felis a nulla aliquet varius. Fusce eget pretium lacus. Nulla\mynote{here another} leo massa, efficitur cursus dictum a, rutrum non ipsum. Proin condimentum, odio et dictum varius, ante sem mattis est, vitae congue odio metus nec nibh. Integer euismod viverra condimentum. Aliquam erat\mynote{other} volutpat. Donec ut sapien fringilla, convallis sem quis, malesuada metus. Quisque mollis iaculis erat a egestas. Nullam lacinia tortor ac vehicula pellentesque. Aliquam sollicitudin viverra ultricies. Sed tincidunt ex dolor, ac malesuada metus commodo id. Cras porttitor in dolor a dapibus. Proin sagittis velit in ligula consequat, at interdum erat rhoncus.

Suspendisse ac viverra augue. Quisque posuere vehicula elementum. Suspendisse potenti. Etiam ac posuere arcu. Nulla convallis magna vel massa fringilla, ut rutrum orci lobortis. Pellentesque mi nibh, rutrum at pulvinar a, scelerisque sed velit. In hac habitasse platea dictumst. Etiam rhoncus dolor lacus. Nam ac lacus id mauris vehicula lobortis quis vel arcu. Nulla vestibulum, turpis quis posuere mattis, diam arcu dictum magna, non laoreet mauris purus non purus. Aliquam eu lacus sit amet velit auctor vulputate. Nulla non sapien blandit, mattis metus in, congue ante. Nam interdum, nunc dignissim fringilla dictum, libero tortor feugiat leo, nec elementum purus arcu sit amet justo. 

\pagebreak


 Lorem ipsum dolor sit amet\mynote{here one note}, consectetur adipiscing elit. Nulla a felis a nulla aliquet varius. Fusce eget pretium lacus. Nulla\mynote{here another} leo massa, efficitur cursus dictum a, rutrum non ipsum. Proin condimentum, odio et dictum varius, ante sem mattis est, vitae congue odio metus nec nibh. Integer euismod viverra condimentum. Aliquam erat\mynote{other} volutpat. Donec ut sapien fringilla, convallis sem quis, malesuada metus. Quisque mollis iaculis erat a egestas. Nullam lacinia tortor ac vehicula pellentesque. Aliquam sollicitudin viverra ultricies. Sed tincidunt ex dolor, ac malesuada metus commodo id. Cras porttitor in dolor a dapibus. Proin sagittis velit in ligula consequat, at interdum erat rhoncus.

Suspendisse ac viverra augue. Quisque posuere vehicula elementum. Suspendisse potenti. Etiam ac posuere arcu. Nulla convallis magna vel massa fringilla, ut rutrum orci lobortis. Pellentesque mi nibh, rutrum at pulvinar a, scelerisque sed velit. In hac habitasse platea dictumst. Etiam rhoncus dolor lacus. Nam ac lacus id mauris vehicula lobortis quis vel arcu. Nulla vestibulum, turpis quis posuere mattis, diam arcu dictum magna, non laoreet mauris purus non purus. Aliquam eu lacus sit amet velit auctor vulputate. Nulla non sapien blandit, mattis metus in, congue ante. Nam interdum, nunc dignissim fringilla dictum, libero tortor feugiat leo, nec elementum purus arcu sit amet justo. 


\end{document}
2
  • Thank you! But now I have another big problem, when I add a new page, everything go wrong, the document invert the pages and the numbers disappears, and I do not know what to do, To see this, just do a \newpage and copy the anterior text,
    – Gergian
    Commented Apr 24, 2018 at 20:53
  • @BozenoBozilson oops. I'll post an update in a bit :-) Commented Apr 24, 2018 at 21:02

You must log in to answer this question.

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