[XeTeX] controlling space above an inline table

Ross Moore ross at ics.mq.edu.au
Sun Sep 13 00:02:18 CEST 2009


Hi Michiel,

On 13/09/2009, at 5:07 AM, Michiel Kamermans wrote:

> Hi all,
>
> I'm kind of running out of ideas... I have what amounts to an  
> inline table (using tabular environment) in order to effect  
> phonetic guide text for CJK text in a document, which works quite  
> well (thanks to Will, Werner and Heiko back in 2008) except that it  
> suffers from one problem that I hadn't noticed back then: there  
> appears to be way too much vertical space, either because of the  
> mbox command or tabular environment, that I can't seem to get rid of.

The problem is here:

\newcommand*{\rubystack}[2]{%
   \begin{tabular}[b]{@{}c@{}}%
     {\tiny#1}\\%
     {\normalsize#2}%
   \end{tabular}%
}

In the first row you are putting \tiny content into
a \normalsize row of text, since by default you will be
using this tabular within a normal paragraph.

Thus you seem to have a lot of extra space, since
the tiny ruby doesn't fill out the full amount
that the \baselineskip is set to, when the \\ is
encountered at the end of that first row.


> The attached pdf should highlight the problem: there is too much  
> space between a line that has text with phonetic guide text, and  
> previous lines.

Here's a way to fix that:

\newcommand*{\rubystack}[2]{{\tiny
   \begin{tabular}[b]{@{}c@{}}%
     {\tiny#1}\\%
     {\normalsize#2}%
   \end{tabular}}%
}

Now the \baselineskip for the 1st row is set by the first \tiny .
while the \normalsize in the 2nd row forces expands that row's height
to accommodate its content.

The image shows what I get, with boxes indicating the space allocated
where I don't have your CJK font installed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 30.png
Type: image/png
Size: 42556 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20090913/405295c4/attachment-0001.png>
-------------- next part --------------

> I tried some negative valued \vspace commands in strategic  
> locations, but couldn't solve it that way, so if a \setlength for  
> some mbox or tabular attribute is required... I have no idea which  
> one. I think I tried every possible attribute that applies to boxes  
> and tables at this point, but to no avail.
>
> Can anyone help?

Hope this helps,

	Ross


>
> Regards,
>
> - Mike "Pomax" Kamermans
> nihongoresources.com
> \documentclass[12pt, openright, a4paper]{book}
>
> \usepackage{fontspec}
>
> % which fonts to use:
> \newcommand{\cjkfont}{\setmainfont{Kozuka Mincho Pro R}}
> \newcommand{\rmfont}{\setmainfont{Palatino Linotype}}
>
> % and just to make sure we're on the roman font by default:
> \rmfont
>
> % set up inter-charclass behaviour
> \XeTeXinterchartokenstate = 1
>
> % when going from not CJK to CJK
> \XeTeXinterchartoks 0 1 = {\cjkfont}
> \XeTeXinterchartoks 0 2 = {\cjkfont}
> \XeTeXinterchartoks 0 3 = {\cjkfont}
>
> \XeTeXinterchartoks 255 1 = {\cjkfont}
> \XeTeXinterchartoks 255 2 = {\cjkfont}
> \XeTeXinterchartoks 255 3 = {\cjkfont}
>
> % when going from CJK to not CJK
> \XeTeXinterchartoks 1 0 = {\rmfont}
> \XeTeXinterchartoks 2 0 = {\rmfont}
> \XeTeXinterchartoks 3 0 = {\rmfont}
>
> \XeTeXinterchartoks 1 255 = {\rmfont}
> \XeTeXinterchartoks 2 255 = {\rmfont}
> \XeTeXinterchartoks 3 255 = {\rmfont}
>
> % ruby markup commands
> \usepackage{accsupp}
> \usepackage[xetex,  pdfborder=0 0 0]{hyperref}
>
> \newcommand*{\rubystack}[2]{%
>   \begin{tabular}[b]{@{}c@{}}%
>     {\tiny#1}\\%
>     {\normalsize#2}%
>   \end{tabular}%
> }
>
> \DeclareRobustCommand*{\ruby}[2]{%
>   \mbox{%
>     \BeginAccSupp{method=pdfstringdef,ActualText={#1}}% effects  
> searching in pdf ignoring ruby text
>       \rubystack{\phantom{#2}}{#1}%
>       \llap{%
>         \rubystack{#2}{\phantom{#1}}%
>       }%
>     \EndAccSupp{}%
>   }%
> }
>
> \pdfstringdefDisableCommands{%
>   \renewcommand*{\ruby}[2]{#2 (#1)}% #1 for base, #2 for just furi,  
> #2 (#1) for the logical choice =)
> }
>
> \begin{document}
>
> \section{Section title}
>
> Finally, in the fourteenth century, during the most famous of  
> Chinese dynasties -- the Ming Dynasty -- there was another influx  
> of Chinese. This influx came from two fronts: firstly, the  
> merchants doing business with the Chinese brought back home  
> readings that are referred to as \ruby{??}{????}, to'on,  
> and secondly from Zen monks who went to study Zen Buddhism in China  
> and brought back readings that are referred to as \ruby{??}{? 
> ???}, so'on. Rather than a single exchange, this was an  
> ongoing effort, and so ?? readings tend to span from the late  
> thirteenth century to well into the Edo period (\ruby{????} 
> {?????}, edojidai), also known as the Tokugawa period  
> (\ruby{????}{???????}, tokugawajidai) running  
> from the seventeenth to the late nineteenth century.
>
> \end{document}<texated.pdf>

------------------------------------------------------------------------
Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------





More information about the XeTeX mailing list