2

I use the linguex package for numbering my examples. After each example I want there to be a reference, right aligned on the next line. This is my code

\documentclass [a4paper, 12 pt]{memoir}

\usepackage[cyr]{aeguill}

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}

\usepackage[francais]{babel}

\usepackage{linguex}

\begin{document}

\ex. This is an example that is too long for me to use the hfill-command. This is an example that is too long for me to use the hfill-command This is an example that is too long for me to use the hfill-command   \begin{flushright}(Reference 2014)\end{flushright}

\ex. This is an example that is too long for me to use the hfill-command This is an example that is too long for me to use the hfill-command This is an example that is too long for me to use the hfill-command \begin{flushright}(Reference 2014b)\end{flushright}

\end{document}

The problem is that the reference between the examples comes with an equal distance to the preceding and the following example. I want the reference to follow the example with not extra vertical space, so that the only added space is between the examples.

I have tried using \raggedright instead of flushright, but the problem persists.

Best, Christine

karlkoeller
  • 124,410

1 Answers1

5

Adding some negative vertical space inside the flushright environment should solve the problem.

Something like:

\begin{flushright}\vspace*{-.65\baselineskip}(Reference 2014)\end{flushright}

MWE:

\documentclass [a4paper, 12 pt]{memoir}

\usepackage[cyr]{aeguill}

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}

\usepackage[francais]{babel}

\usepackage{linguex}

\begin{document}

\ex. This is an example that is too long for me to use the hfill-command 
This is an example that is too long for me to use the hfill-command 
This is an example that is too long for me to use the hfill-command 
\begin{flushright}\vspace*{-.65\baselineskip}(Reference 2014)\end{flushright}

\ex. This is an example that is too long for me to use the hfill-command 
This is an example that is too long for me to use the hfill-command 
This is an example that is too long for me to use the hfill-command 
\begin{flushright}\vspace*{-.65\baselineskip}(Reference 2014b)\end{flushright}

\end{document} 

Output:

enter image description here

By the way, the "command-form" of flushright is \raggedleft and not \raggedright.


EDIT

The best thing should be to define a new command, let's say \flushfill, that is able to fill the line when there is enough room otherwise it has to flush the text right in the following line.

Following a trick described in this answer of David Carlisle, we can define:

\newcommand{\flushfill}[1]{\hspace{\fill}\mbox{}\linebreak[0]\hspace*{\fill}\mbox{#1}}

and use it as follows:

\documentclass [a4paper, 12 pt]{memoir}

\usepackage[cyr]{aeguill}

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}

\usepackage[francais]{babel}

\usepackage{linguex}

\newcommand{\flushfill}[1]{\hspace{\fill}\mbox{}\linebreak[0]\hspace*{\fill}\mbox{#1}}

\begin{document} 

\ex. This is an example that is too long for me to use the hfill-command
This is an example that is too long for me to use the hfill-command
This is an example that is too long 
\flushfill{(Reference 2014)}

\ex. This is an example that is too long for me to use the hfill-command
This is an example that is too long for me to use the hfill-command
This is an example that is too long for me to use the
\flushfill{(Reference 2014a)}

\ex. This is an example that is too long for me to use the hfill-command
This is an example that is too long for me to use the hfill-command
This is an example that is too long for me to use the hfill-command
\flushfill{(Reference 2014b)}

\end{document} 

Output:

enter image description here

karlkoeller
  • 124,410
  • Thanks a lot! These are very useful tips!

    I couldn't get \flushfill to be right aligned on the next page when the "references" were too long. Any idea as to why? I just copied the code above.

    – Meklenborg Jan 13 '14 at 22:03
  • @Christine "references" cannot be longer than a line since they are inside a box... Anyway, if the answer solves your problem, consider accepting it. See How do you accept an answer? – karlkoeller Jan 13 '14 at 22:09