Upload
others
View
12
Download
0
Embed Size (px)
Citation preview
Creating a Table of Contents for MS Word using AutoFormat and Cascading Style Sheets
Fareeza Khurshed
Overview
Motivation
Methods to create a table of contents
CSS Method to create a TOC
Style Sheets
Conclusion
Motivation
If it looks like a duck, quacks like a duck…
Word TOC can be created based on Heading 1/Heading 2/Heading 3
If text in document LOOKS like Heading 1/Heading 2/Heading 3 will Word recognize them as ‘Headings’ and use in TOC?
Can the TOC incorporate BY GROUP titles?
Creating a TOC – Method 1
Using options statement in ODS RTF
CONTENTS=Yes/TOC_DATA options
Pros:
Easy
Cons:
Multiple redundant listings for the same proc
ODS RTF FILE='C:\temp\test_method1.rtf' CONTENTS=yes TOC_DATA;
ODS PROCLABEL=‘this is my sample title’;
Creating a TOC – Method 2
Wordstyle option in ODS RTF statement
Need to embed RTF commands in the text lines
Pros:
Can customize in code
Cons:
Experimental and undocumented
By Group processing?
Creating a TOC – Method 2
ODS RTF FILE='C:\temp\test_method2.rtf' WORDSTYLE="{\s1 Heading 1;}{\s2 Heading 2;}" ;
ODS ESCAPECHAR=‘\’;
ODS RTF TEXT='\R/RTF"\s1 " Car Analysis';
Creating a TOC – Method 3
RTF Syntax
Commands embedded in title, text or prepage statements
Pros:
Versatile and programmable
By Groups (untested)
For full report automation, best method
Cons:
Additional syntax knowledge
Output and code similar to Method 2
Creating a TOC – CSS Method
1. Create a stylesheet
2. Use stylesheet in ODS RTF output
3. AutoFormat
4. Insert TOC in Word
Cascading Style Sheets
Used primarily in webpage design
Useful for separating content and data
Reusable
Different versions: CSS2, CSS3
SAS currently supports CSS2
Cascading Style Sheets
.title{…}
.header1{…}
.table{…}
.tableheader{…}
<header1>This is my
header</header1>
<table>
….
</table>
Formatting instructions Contents
Final Presentation
This is my header
Cell1 Cell2
Cell3 Cell4
If you want to change the
appearance of the
document, change the
formatting instructions (not
content) and the
presentation changes.
Cascading Style Sheets
SAS has CSS templates predesigned
Template class names are unique to implementation so modifying a SAS template is recommended
Can be aligned with corporate style sheets if desired
Style sheets viewable in source code from websites
EG Style Editor
Can be edited in any text editor
Cascading Style Sheets
.systemtitle{
font-family: Arial, Helvetica, sans-serif;
font-size:16pt;
font-weight: bold;
color: black;
text-align:left;
}
Creating a TOC – CSS Method
ODS RTF FILE="c:\temp\TOC.rtf"
CSSSTYLE="H:\...\stylesheet_test3.css"
BODYTITLE
STARTPAGE=never;
Creating a TOC – CSS Method
TITLE 'Car Analysis';
PROC FREQ DATA=cars (where= (make in ("Honda", "Hyundai", "Ford")));
BY make;
TABLES type;
RUN;
….
ODS RTF CLOSE;
Creating a TOC – CSS Method
Car Analysis ....................................................................................................................... 1
Make=Ford..................................................................................................................... 1
Make=Honda.................................................................................................................. 1
Make=Hyundai............................................................................................................... 1
Average Mileage ................................................................................................................ 1
Creating a TOC – CSS Method
Pros:
Familiar syntax
By Group headings
‘Standard’ Word format
Cons:
Need to create CSS file for each format used in the document, ie prepage, usertext
Manual steps in Word
If titles appear on multiple pages they will appear in the TOC multiple times.
Conclusion
Multiple methods of creating TOC
For customized, routine reports use Method 3
For quick reports with readable TOC CSS style method is useful, especially where text will be written around tables/graphs
References
Zender, Cynthia. 2009. “CSSSTYLE: Stylish Output with ODS and SAS 9.2”. Proceedings of the SAS Global Forum 2009 Conference. Cary, NC. SAS Institute Inc. 014-2009
Small, Electra. 2007. “Creating Table of Contents in RTF Documents”. Proceedings of the SAS Global Forum 2007 Conference. Cary, NC. SAS Institute Inc. 097-2007.
Acknowledgements
Thanks to Colleen McGahan and Ryan Woods at the BC Cancer Agency for assistance in developing and editing this paper.