2

I'm running into a situation where I need to insert some code (specifically, \hfill) only if my paragraph runs more than one line. This isn't a simple alignment thing, as I'm working with right-to-left text interaction with left-to-right text on the same line, and anyway, this is what it's come to. Does anyone know if there's an internal variable LaTeX sets when it moves text onto the next line, and how I might use that to do something like (note, I don't know how to use conditional code in LaTeX, so this is heuristic):

\if\multiline\then{ \hfill}.

EDIT:

I need an \hfill in a right-to-left environment, which TeX doesn't automatically provide. I have something like:

    \newcommand{\hangparag}[2]{\hangindent#1 \hangafter#2 \leftskip 0.5em \parindent -0.5em}
    \newcommand{\entry}[2]{\hangparag{-0.5em}{1}{\textbf{#1} #2}\par}
    \newcommand{\h}[1]{\hspace{0.5cm}\RL{\texthebrew{#1}\hfill}}

    \flushright
    \entry{Z}{\h{דער זעט, ־ן}}

I was having trouble with the double-sided indents when the translation was on a second line, but \hfill fixed that, but now if I want to add English text next to the translation, with one-line translations, I have an \hfill pushing my English over to the side of my definition. For example:

    \entry{zany}{[MEShÚGE] \h{משוגע}}

ends up with with the transcription somewhere in between "zany" and "משוגע", when I actually want it next to "משוגע".

MINIMAL EXAMPLE:

\documentclass[10pt]{book}
\usepackage{polyglossia}
\usepackage{multicol}
\newcommand{\hangparag}[2]{\hangindent#1 \hangafter#2 \leftskip 0.5em \parindent -0.5em}
\setdefaultlanguage{english}
\setotherlanguages{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Microsoft Sans Serif}
\newcommand{\entry}[2]{\hangparag{-0.5em}{1}{\textbf{#1}\hspace{0.5cm}\hfill #2}\par}
\newcommand{\h}[1]{\RL{\texthebrew{#1}\hfill}}
\begin{document}
\flushright
\setlength{\columnseprule}{0.4pt}
\begin{multicols*}{2}
\entry{Z, n. (letter)}{\h{דער זעט, ־ן}}
\entry{zany}{[MEShÚGE] \h{משוגע}}
\entry{zeal}{\h{דאָס התלהבֿות; דער ברען; די התמדה; דער אײפֿער; דאָס/די פֿאַרברענטקײט}}
\end{multicols*}
\end{document}
5
  • 3
    It's not very clear what you need, since TeX adds automatically \hfill at the end of a paragraph. Would you please add a "real life" example?
    – egreg
    Jul 22, 2011 at 9:11
  • He/She might be working in verbatim environment enclosing long characters that cannot be split across lines. Jul 22, 2011 at 9:38
  • Check my updated question, hopefully that will clarify.
    – magicker72
    Jul 22, 2011 at 10:18
  • Not quite clearer. You should provide a minimal preamble so that we can try compiling the sample.
    – egreg
    Jul 22, 2011 at 10:23
  • I've given an example with three entries, one normal, one with English transcription, and one with multi-line.
    – magicker72
    Jul 22, 2011 at 10:32

1 Answer 1

1

I would simply change \hfill in the definition of \h into \hfil: this is a "lower order infinity" stretching space that is defeated by the \hfill provided by the paragraph end.

1
  • Thank you very much! If you're already looking at this, I have another question regarding the right-to-left/left-to-right interaction... if I have a two line translation with transliteration, eg. \entry{zeal}{[HISLÁYVES] [HASMÓDE] \h{דאָס התלהבֿות; דער ברען; די התמדה; דער אײ֨פֿער; דאָס/די פֿאַרברע֨נטקײט}} I would like for the English to be pushed onto the second line. Do you know how that would be possible? Should I ask this in a separate question? Thanks again.
    – magicker72
    Jul 22, 2011 at 14:44

You must log in to answer this question.

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