XSL-FO Tutorials - Herong's Tutorial Examples - v2.25, by Herong Yang
What Is "baseline-shift" Attribute?
This section describes 'baseline-shift' attribute for 'inline' formatting object. It is used to shift the baseline of output inline area relatively from the baseline of the parent line area.
What Is "baseline-shift" Attribute? "baseline-shift" is an attribute for inline-level formatting objects to specify how much to shift the baseline of the output inline area relative to the baseline of the parent line area.
"baseline-shift" attribute can be specified with different types of value:
Here is my tutorial example, inline-baseline-shift-Attribute.fo, that shows two "inline" formatting objects with "baseline-shift" specified:
<?xml version="1.0" encoding="utf-8"?>
<!-- inline-baseline-shift-Attribute.fo
- Copyright (c) 2006 HerongYang.com. All Rights Reserved.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
margin="0.1in" page-height="4in" page-width="3in">
<fo:region-body region-name="body" background-color="#eeeeee"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:flow flow-name="body">
<fo:block margin="0.1in" padding="0.2in"
border-width="1px" border-style="solid"
background-color="#eeffff" color="#000000"
text-align="justify" font-family="sans-serif">
Once upon a time there
pigs<fo:inline baseline-shift="super" background-color="#ffeeee"
font-size="70%">[who lived with their Mother]</fo:inline>.
Early one morning they woke up and their mother said,
"you're too big for this
house<fo:inline baseline-shift="sub" background-color="#ffeeee"
font-size="70%">[and its time you left home]</fo:inline>."
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
If you process this example XSL-FO document with Apache FOP tool, you should see a subscript and a superscript highlighted:
Table of Contents
Apache™ FOP (Formatting Objects Processor)
XSL-FO Document Basics and Examples
Block-Level Formatting Objects
►Inline-Level Formatting Objects
What Are Inline-Level Formatting Objects?
What Is "inline" Formatting Object?
"inline" Splitting for Line Break
What Is "line-height" Attribute?
►What Is "baseline-shift" Attribute?
FOP Failed on "block" inside "inline"
What Is "inline-container" Formatting Object?
What Is "character" Formatting Object?
What Is "leader" Formatting Object?
What Are "page-number*" Formatting Objects?
Including Graphics in XSL-FO document
Floating Blocks - "float" and "footnote"
Hyperlinks, Table of Contents and Indexes
Headers and Footers using "static-content"
Font Attributes and Font Families
Apache FOP Font Configurations