3

I have to merge two lengthy files, one of which is using the marginnote package and the other needs the parskip package. If I use them at the same time the command I use to label years in the margin, say \years, doesn't work as It should.

Following I am showing a code for example.

\documentclass{article} 
\usepackage{marginnote,parskip}
\reversemarginpar
\newcommand{\years}[1]{\marginnote{#1}}
\newcommand{\degree}[5][in]{\years{#2}\textsc{#3} #1 \emph{#4}, \textsc{#5}\\}
\begin{document}

\section*{Degrees}
\degree[on]{2017--2018}{Postdoctoral Research}{Computational Mathematics}{Somewhere}
\degree{2011--2017}{PhD}{Computational Commutative Algebra}{Somewhere}
\degree{1999--2002}{M.Sc.}{General Topology}{Somewhere}
\degree{1995--1999}{B.Sc.}{Pure Mathematics w/ minor in physics}{Somewhere}


\end{document}

You can compare the result of the code above and the result of the following code:

\documentclass{article} 
\usepackage{marginnote}
\reversemarginpar
\newcommand{\years}[1]{\marginnote{#1}}
\newcommand{\degree}[5][in]{\years{#2}\textsc{#3} #1 \emph{#4}, \textsc{#5}\\}
\begin{document}

\section*{Degrees}
\degree[on]{2017--2018}{Postdoctoral Research}{Computational Mathematics}{Somewhere}
\degree{2011--2017}{PhD}{Computational Commutative Algebra}{Somewhere}
\degree{1999--2002}{M.Sc.}{General Topology}{Somewhere}
\degree{1995--1999}{B.Sc.}{Pure Mathematics w/ minor in physics}{Somewhere}


\end{document}

Can anyone help?

  • Your both codes looks identical to me. Where is the difference? – Ulrike Fischer Aug 11 '18 at 10:33
  • @UlrikeFischer I edited the question... they should be different in having parskip in line 2. – Omid Ghayour Aug 11 '18 at 17:07
5

In your example you are missing one of the arguments of your \degree command: It has 5 mandatory arguments but are only giving 4.

Beside this, it is normally better not to issue \marginnote in vertical mode, when the paragraph hasn't started yet. Move the command behind the first word, or use e.g. \leavevmode. I would also end the \degree with \par and not \\:

\documentclass{article}
\usepackage{marginnote,parskip}
\reversemarginpar
\newcommand{\years}[1]{\marginnote{#1}}
\newcommand{\degree}[6][in]{\leavevmode\years{#2}\textsc{#3} #1 \emph{#4}, #5, \textsc{#6}\par}
\begin{document}

\section*{Degrees}

\degree[on]{2017--2018}{Postdoctoral Research}{Computational Mathematics}{Somewhere}{}
\degree{2011--2017}{PhD}{Computational Commutative Algebra}{Somewhere}{}
\degree{1999--2002}{M.Sc.}{General Topology}{Somewhere}{}
\degree{1995--1999}{B.Sc.}{Pure Mathematics w/ minor in physics}{Somewhere}{}


\end{document}

enter image description here

  • I edited the question... and also removed the 6th argument in the command definition... my question still exists if you remove the parskip you will see the result will change to what I really dislike, WHY? – Omid Ghayour Aug 11 '18 at 17:12
  • As I already wrote: use \leavevmode. – Ulrike Fischer Aug 11 '18 at 17:20
  • As I said... If you use \leavevmode at the beginning and \par at the end of the command you will still see the outputs are different when using parskip and not. – Omid Ghayour Aug 11 '18 at 17:39
  • I used \leavevmode at the beginning and \\ at the end of the command... and found the results are same using or not using parskip except an extra blankspace after the section title, say Degrees. this should have a little care for cure, too. – Omid Ghayour Aug 11 '18 at 17:42
  • You have different dashes in your code. the first one is shorter. – Ulrike Fischer Aug 11 '18 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.