2
\documentclass{article}
 \usepackage{linguex}

 \begin{document}


\ex. Some Example French sentence \hfill(French)\\
This  is the gloss\\
`the interpretation'


\exg. Some Example French sentence \hfill(French)\\
This  is the gloss\\
`the interpretation'

\end{document}

enter image description here

The (French) in example 2 is supposed to flush to the right; just like the first example.

There seems to exist some kind of conflict with the exg command. Any help please

2
  • Can you please provide the code of a complete document, starting with \documentclass and ending with \end{document} that shows your problem, to save us the work of making up a compilable document?
    – gernot
    Jan 28 '17 at 9:53
  • OK, I am adding it
    – Dellu
    Jan 28 '17 at 12:06
2

The \exg command is much more complicate than \eg, because it parses the text to horizontally align the words of two lines.

Some TeX engines (pdfTeX, LuaTeX, XeTeX) support the "savepos" feature. It allows to record the current position (unit is sp) in the .aux file to be evaluated in the next TeX run.

The following example uses this feature together with zref, a packages that provides more flexible label/ref system than the standard \label/\ref provides.

\RequirePackage{ifluatex}
\ifluatex
  \IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{}
\fi

\documentclass[twoside]{article}
\usepackage[
  a6paper,
  landscape,
  vmargin=1cm,
  includeheadfoot,
  showframe, % for reviewing
]{geometry}

\usepackage{linguex}

\usepackage{zref-savepos}

\makeatletter
\zref@newprop*{PageValue}[1]{\the\c@page}%
% Counter
\newcount\eolpos@cnt
\eolpos@cnt=\z@
\newcommand*{\eolpos@label}{eolpos\the\eolpos@cnt}
\newcommand*{\eolpos}{}
\protected\def\eolpos#1{%
  \leavevmode
  \rlap{%
    % Unique label names
    \global\advance\eolpos@cnt\@ne
    % Save the current horizontal position along
    % with the value of the page counter
    \zref@savepos
    \zref@labelbyprops{\eolpos@label}{posx, PageValue}%
    % Measure part
    \sbox\z@{#1}%
    \dimen@=\z@
    \zifrefundefined{\eolpos@label}{%
    }{%
      \dimen@=\dimexpr
        \expandafter\ifx\csname pdfhorigin\endcsname\relax
          1in%
        \else
          \pdfhorigin
        \fi
        +%
        \ifodd\zref@extractdefault{\eolpos@label}{PageValue}\@ne
          \oddsidemargin
        \else
          \evensidemargin
        \fi
        +\textwidth
        -\wd\z@
        -\zref@extractdefault{\eolpos@label}{posx}{0}sp%
      \relax
    }%
    % Set space
    \ifdim\dimen@<\z@
      \typeout{`eolpos` warning: Text sticks to the left by \the\dimen@}%
    \fi
    \kern\dimen@
    % Place user text
    \usebox\z@
  }%
}
% \z@ = 0 or 0pt
% \@ne = 1
% \dimen@ = \dimen0
\makeatother

\begin{document}

\ex. Some Example French sentence \hfill(French)\\
This  is the gloss\\
`the interpretation'

\exg. Some Example French sentence \eolpos{(French)}\\
This  is the gloss\\
`the interpretation'

\newpage
\ex. Some Example French sentence \hfill(French)\\
This  is the gloss\\
`the interpretation'

\exg. Some Example French sentence \eolpos{(French)}\\
This  is the gloss\\
`the interpretation'

\end{document}

Page 1:

Page 1

Page 2:

Page 2

2

\hfill does only work on the third line of glossed examples with linguex, which might be an option for you. Alternatively, Brian Buccola has a work-around on his website here.

2
  • Welcome to TeX.sx. Please add context around the link so other users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.
    – cgnieder
    Apr 27 '17 at 10:32
  • yes, I am using his trick. I was hopping for a permanent fix for this.
    – Dellu
    Apr 28 '17 at 13:42

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