Justifying a Heading, Footing, Title, or Label

In this section:

You can left-justify, right-justify, or center the following report elements:

In addition, you can use justification syntax in combination with other StyleSheet syntax to align headings and footings with other report elements, based on either unit measurements or relationships to other report elements, such as columns. For a summary of these options, see Choosing an Alignment Method for Heading and Footing Elements.

Justifying a Heading or Footing

How to:

Reference:

You can left-justify, right-justify, or center a heading or footing in a StyleSheet. By default, a heading or footing is left justified. In addition, you can justify an individual line or lines in a multiple-line heading or footing.

To center a page heading or footing over the report data, you can use a legacy formatting technique that does not require a StyleSheet; simply include the CENTER command in a HEADING or FOOTING command.

Justification behavior in HTML and PDF. For HTML reports, justification is implemented with respect to the report width. That means a centered heading is centered over the report content. In contrast, for PDF reports the default justification area is the page width, rather than the report width, resulting in headings and footings that are not centered on the report. In most cases, you can achieve justification based on report width in a PDF report by adding the command SET SQUEEZE=ON to your request. This command improves the appearance of the report by eliminating excessive white space between columns and implements justification over the report content. However, if the heading is wider than the report, it will be centered on the page, even when SQUEEZE=ON.

Tip: You can also use justification syntax in combination with other StyleSheet syntax to align headings, footings, and items in them with other report elements, based on either unit measurements or relationships to other columns. For a summary of these options, see Choosing an Alignment Method for Heading and Footing Elements.

Syntax: How to Justify a Heading or Footing in a StyleSheet

TYPE = headfoot, [LINE = line_#,] JUSTIFY = option, $

where:

headfoot
Is the type of heading or footing. Valid values are TABHEADING, TABFOOTING, HEADING, FOOTING, SUBHEAD, and SUBFOOT.
line_#
Optionally identifies a line by its position in the heading or footing so that you can individually align it. If a heading or footing has multiple lines and you omit this option, the value supplied for JUSTIFY applies to all lines.
option
Is the type of justification. Valid values are:

LEFT which left justifies the heading or footing. LEFT is the default value.

RIGHT which right justifies the heading or footing.

CENTER which centers the heading or footing.

For an alternative way to center a page heading or footing without a StyleSheet, see Center a Page Heading or Footing Using Legacy Formatting.

Note: JUSTIFY is not supported with WRAP.

Example: Justifying a Report Heading

This request centers the report heading PRODUCT REPORT, using the attribute JUSTIFY = CENTER.

TABLE FILE GGPRODS
SUM UNITS BY PRODUCT_DESCRIPTION BY PRODUCT_ID BY VENDOR_NAME
ON TABLE SUBHEAD
"PRODUCT REPORT"
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $
TYPE = REPORT, COLUMN = VENDOR_NAME, JUSTIFY = CENTER, $ 
TYPE = TABHEADING, JUSTIFY = CENTER, $ 
ENDSTYLE
END

The output is:

Tip: If you wish to run this report in PDF format, add the code ON TABLE SET SQUEEZE ON to eliminate excessive white space between columns and to center the heading over the report.

For more information on justifying a column title, see Justifying a Column Title.

Example: Justifying Individual Lines in a Multiple-Line Report Heading

In this request, heading line 1 (SALES REPORT) is centered, heading line 2 (**CONFIDENTIAL**) is also centered, and heading line 3 (December 2001) is right justified.

TABLE FILE GGSALES
SUM BUDUNITS UNITS BUDDOLLARS DOLLARS
BY CATEGORY
ON TABLE SUBHEAD
"SALES REPORT"
"**(CONFIDENTIAL)**"
"December 2001"
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $ 
TYPE = TABHEADING, LINE = 1, JUSTIFY = CENTER, $
TYPE = TABHEADING, LINE = 2, JUSTIFY = CENTER, $
TYPE = TABHEADING, LINE = 3, JUSTIFY = RIGHT, $ 
ENDSTYLE
END

The output is:

Tip: To run this report in PDF format, add the code ON TABLE SET SQUEEZE ON to eliminate excessive white space between columns and to center the heading over the report.

Example: Centering All Lines in a Multiple-Line Report Heading

This request centers all lines in a multiple-line report heading using the single StyleSheet attribute for the entire heading.

TABLE FILE GGSALES
SUM BUDUNITS UNITS BUDDOLLARS DOLLARS
BY CATEGORY
ON TABLE SUBHEAD
"SALES REPORT"
"**(CONFIDENTIAL)**"
"December 2001"
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $ 
TYPE = TABHEADING, JUSTIFY = CENTER, $ 
ENDSTYLE
END

The output is:

Tip: To run this report in PDF format, add the code ON TABLE SET SQUEEZE ON to eliminate excessive white space between columns and to center the heading over the report.

Reference: Justification Regions and Behavior

The region in which text is justified depends on the relationship of the sizes of certain elements in the report:

  • When SQUEEZE=ON, the maximum width of all the heading types in the report is calculated. This value is called MaxHeadWidth.

    If MaxHeadWidth is less than or equal to the total width of the columns of the report, headings are justified in the space over the report columns.

    If MaxHeadWidth exceeds the total width of the columns of the report, headings are centered and right-justified in the entire width of the page.

  • When SQUEEZE=OFF, the maximum width of all the headings are not pre-calculated. Headings are centered in the entire width of the page.

    With a styled, multiple-panel report (in which the width exceeds one page), headings can only appear in the first panel. Thus, the preceding calculations deal with the total width of the columns in the first panel rather than the total width of all the columns in the report.

Syntax: How to Center a Page Heading or Footing Using Legacy Formatting

{HEADING|FOOTING} CENTER
 "content ... "
["content ... "]
.
.
.
["content ... "]

where:

HEADING
Is a page heading.
FOOTING
Is a page footing.
CENTER
Centers the page heading or footing over or under the report data.
content
Heading or footing content can include the following elements, between double quotation marks. If the ending quotation mark is omitted, all subsequent lines of the request are treated as part of the heading or footing.
text
Is text for the heading or footing. You can include multiple lines of text.

The text must start on a line by itself, following the HEADING or FOOTING command.

Text can be combined with variables and spot markers.

For related information, see Limits for Headings and Footings.

variable
Can be any one or a combination of the following:

Fields (real data source fields, a virtual fields created with the DEFINE command in a Master File or report request, calculated values created with the COMPUTE command in a request, a system field such as TABPAGENO). You can qualify data source fields with certain prefix operators.

Dialogue Manager variables.

Images. You can include images in a heading or footing.

For details, see Including an Element in a Heading or Footing.

spot marker
Enables you to position items, to identify items to be formatted, and to extend code beyond the 80-character line limit of the text editor.

<+0> divides a heading or footing into items for formatting. For details, see Identifying a Heading, Footing, Title, or FML Free Text.

</n specifies skipped lines. For details, see Controlling the Vertical Positioning of a Heading or Footing.

<-n to position the next character on the line. For details, see Using Spot Markers to Refine Positioning.

<0X continues a heading or footing specification on the next line of the request. For details, see Extending Heading and Footing Code to Multiple Lines in a Report Request.

Note: When a closing spot marker is immediately followed by an opening spot marker (><), a single space text item will be placed between the two spot markers (> <). This must be considered when applying formatting.

Blank lines
If you omit all text, variables, and spot markers, you have a blank heading or footing line (for example, " ") which you can use to skip a line in the heading or footing. (You can also skip a line using a vertical spot marker, such as </1.)

Tip: Do not use the command CENTER with the StyleSheet attribute JUSTIFY = CENTER. A single method will generate the desired result.

Example: Centering a Page Heading

This request uses the command CENTER in the page heading syntax.

TABLE FILE EMPLOYEE 
HEADING CENTER 
"ACCOUNT REPORT FOR DEPARTMENT <DEPARTMENT"
PRINT CURR_SAL BY DEPARTMENT BY HIGHEST BANK_ACCT
BY EMP_ID
ON DEPARTMENT PAGE-BREAK
ON TABLE SET PAGE-NUM OFF
ON TABLE SET WEBVIEWER ON
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, SIZE=10, GRID=OFF,$
ENDSTYLE
END

The page heading is centered over the report data, as shown in the first page of output.

Tip: If you do not see the navigation arrows, click the maximize button.

Justifying a Column Title

How to:

You can left-justify, right-justify, or center a column title for a display field, BY field, ACROSS field, or calculated value using a StyleSheet.

If a title is specified with an AS phrase in a request, or with the TITLE attribute in a Master File, that title will be justified, as specified for the field in StyleSheet syntax, if such syntax exists in the request. For related information, see Customizing a Column Title.

Justification behavior in HTML and PDF. For HTML reports, justification is implemented with respect to the report width. That means a centered column title is centered over a report column. In contrast, for PDF reports the default justification area is the page width, rather than the report width, resulting in column titles that are not centered over the report column. You can achieve justification based on report width in a PDF report by adding the command SET SQUEEZE=ON to your request. This command improves the appearance of the report by eliminating excessive white space between columns and implements justification over the report content.

You can also justify a column title for a display or BY field using legacy formatting methods. However, when legacy formatting is applied to an ACROSS field, data values, not column titles, are justified as specified. See Justify a Column Title for a Display or BY Field Using Legacy Formatting.

Syntax: How to Justify a Column Title Using a StyleSheet

To justify a column title for a vertical sort column (generated by BY) or a display column (generated by PRINT, LIST, SUM, or COUNT), the StyleSheet syntax is

TYPE=TITLE, [COLUMN=column,] JUSTIFY=option, $
TYPE=ACROSSTITLE, [ACROSS=column,] JUSTIFY=option, $
TYPE=ACROSSVALUE, [COLUMN=column,] JUSTIFY=option, $

To justify a horizontal sort column title (generated by ACROSS), the StyleSheet syntax is

TYPE=ACROSSTITLE, [ACROSS=column,] JUSTIFY=option, $

To justify an ACROSS value or a ROW-TOTAL column title in an HTML report, use

TYPE=ACROSSVALUE, [COLUMN=column,] JUSTIFY=option, $

where:

TITLE
Specifies a vertical sort (BY) title or a display field title.
column
Specifies the column whose title you wish to justify. If you omit this attribute and value, the formatting will be applied to all of the report's column titles. For details on identifying columns, see Identifying a Report Component in a WebFOCUS StyleSheet.
ACROSSTITLE
Specifies a horizontal sort (ACROSS) title.
ACROSSVALUE
Specifies a horizontal sort (ACROSS) value or a ROW-TOTAL column title.
option
Is the type of justification. Valid values are:

LEFT which left justifies the column title. This value is the default for an alphanumeric field.

RIGHT which right justifies the column title. This value is the default for a numeric or date field.

CENTER which centers the column title. You cannot center an ACROSSTITLE in a PDF report.

Note: JUSTIFY is not supported with WRAP.

Example: Using a StyleSheet to Justify Column Titles for Display and BY Fields

This request centers the column titles for STORE_NAME and ADDRESS1. The default column title for STORE_NAME is Store Name, as specified in the Master File with the TITLE attribute. The default column title for ADDRESS1 is Contact, also specified in the Master File. The request right-justifies the column title for STATE, which is specified in the AS phrase as St. Each column is identified by its field name and justified separately.

TABLE FILE GGSTORES
PRINT STORE_NAME STATE AS 'St' BY ADDRESS1
WHERE STATE EQ 'CA'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET SQUEEZE ON
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $ 
TYPE=TITLE, COLUMN=STORE_NAME, JUSTIFY=CENTER, $
TYPE=TITLE, COLUMN=STATE, JUSTIFY=RIGHT, $
TYPE=TITLE, COLUMN=ADDRESS1, JUSTIFY=CENTER, $ 
ENDSTYLE
END

The output is:

Example: Using a StyleSheet to Justify a Column Title for ACROSS and ROW-TOTAL Fields

This request centers the column title, State, created by the ACROSS phrase over the two values (MT and WY) and the row total column title, Total by Gender, over the two row totals (Male Population and Female Population). Notice that each across value functions as a title for one or more columns in the report.

TABLE FILE GGDEMOG
SUM MALEPOP98 FEMPOP98
ROW-TOTAL/D12 AS 'Total by Gender'
ACROSS ST
WHERE ST EQ 'WY' OR 'MT';
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $ 
TYPE=ACROSSTITLE, JUSTIFY=CENTER, FONT='TIMES', SIZE=11, STYLE=BOLD, $
TYPE=ACROSSVALUE, COLUMN=N5, JUSTIFY=CENTER, $ 
ENDSTYLE
END

The output is:

Example: Using a StyleSheet to Justify a Column Title for a Calculated Value

This request identifies the column title of the calculated value and left justifies it over the data.

TABLE FILE SALES
SUM UNIT_SOLD RETAIL_PRICE 
COMPUTE REV/D12.2M = UNIT_SOLD * RETAIL_PRICE; 
BY PROD_CODE
WHERE CITY EQ 'NEW YORK'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $ 
TYPE=TITLE, COLUMN=REV, STYLE=BOLD, JUSTIFY=LEFT, $ 
ENDSTYLE
END

The output is:

Note: To run this report in PDF format, add the code ON TABLE SET SQUEEZE ON to eliminate excessive white space between columns and to justify column titles properly over the data.

Syntax: How to Justify a Column Title for a Display or BY Field Using Legacy Formatting

fieldname/justification [/format] [AS 'title']

where:

fieldname
Is the name of the field.
justification
Is the type of justification. Valid values are:

L which left justifies the column title. This value is the default for an alphanumeric field.

R which right justifies the column title. This value is the default for a numeric or date field.

C which centers the column title.

/format
Is an optional format specification for the field. For a display field, you can combine the justification value with the format value (in either order) to adjust the width of the column data or to specify display options.
AS 'title'
Is an optional customized column title.

Tip: For an ACROSS field, this syntax justifies data values, not column titles. For syntax that will justify the title, see Justify a Column Title Using a StyleSheet.

Example: Using Legacy Formatting to Justify Column Titles for Display and BY Fields

This request centers the column titles for STORE_NAME and ADDRESS1. The default column title for STORE_NAME is Store Name, as specified in the Master File with the TITLE attribute. The default column title for ADDRESS1 is Contact, also specified in the Master File. The request right justifies the column title for STATE, which is specified in the AS phrase as St.

TABLE FILE GGSTORES 
PRINT STORE_NAME/C STATE/R AS 'St' BY ADDRESS1/C 
WHERE STATE EQ 'CA'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $
ENDSTYLE
END

The output is:

Note: Add the syntax, ON TABLE SET SQUEEZE ON to your request if you are using PDF format.

Justifying a Label for a Row or Column Total

How to:

You can left-justify, right-justify, or center a label for a row or column total. For related information, see Creating Labels to Identify Data.

Syntax: How to Justify a Label for a Row or Column Total Using Legacy Formatting

ROW-TOTAL/justification [/format] [AS 'label']
COLUMN-TOTAL/justification [AS 'label']

or

COLUMN-TOTAL/justification [AS 'label']

where:

justification
Is the type of justification. Valid values are:

L which Left justifies the label.

R which right justifies the label.

C which centers the label.

/format
Is an optional format specification for a row total. You can combine the alignment value with the format value (in either order) to adjust the width of the column data or specify display options.
AS 'label'
Is an optional customized label.

Example: Centering a Label for a Row Total

This request creates the stacked label Total, Population, by State for the row total and centers it. The format D12 for ROW-TOTAL displays commas by default.

TABLE FILE GGDEMOG
PRINT MALEPOP98 FEMPOP98 
ROW-TOTAL/C/D12 AS 'Total,Population,by State' 
BY ST
WHERE (ST EQ 'WY' OR 'MT')
ON TABLE COLUMN-TOTAL AS 'Total by Gender'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID=OFF, $
ENDSTYLE
END

The output is:

Justifying a Label for a Subtotal or Grand Total

You cannot directly justify a customized label for a subtotal. However, for HTML, EXL2K, or XLSX report output, if columns are being totaled or subtotaled by the one subtotal command, and you do not specify a column in the StyleSheet, formatting is applied to the totals and subtotals of all columns and to the labeling text that introduces the total and subtotal values. For related information, see Identifying a Report Component in a WebFOCUS StyleSheet.

Example: Justifying Subtotal and Grand Total Labels

This request subtotals the numeric columns in the report and right-justifies the output, including the text of the label that precedes the values for the subtotals. Since numeric output is right-justified by default, in this example the justification specifications in the StyleSheet are used to reposition the labels. The default label for the automatically generated grand total is also right-justified.

TABLE FILE EMPLOYEE
SUM DED_AMT BY DED_CODE BY DEPARTMENT
BY BANK_ACCT
WHERE DED_CODE EQ 'CITY'
WHERE BANK_ACCT NE 0 
ON DEPARTMENT SUBTOTAL AS 'Total City Deduction for' 
ON TABLE SET PAGE-NUM OFF
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF, $ 
TYPE=SUBTOTAL, STYLE=BOLD, JUSTIFY=RIGHT,$
TYPE=GRANDTOTAL, STYLE=BOLD, JUSTIFY=RIGHT,$ 
ENDSTYLE
END

The output is: