IntroductionThe main purpose of Show
The following sections describe this process in detail for both Word and PowerPoint documents. Before you get started, copy the provided examples into your current working directory. To do so, use the following code:
This will create the following files:
Mapping and the yaml file formatBefore we start discussing how to create templates we need to talk a little bit about the
This example lays out
The main key in the example above is The color values associated with roots are The The value There is more that can go into a PowerPointThis section provides a detailed walk-through for each of the three steps in the Introduction. We recommend everyone walk through this process at least once. A quick note about terminology. A slide master is the top slide in a hierarchy of slides that stores information about the theme and slide layouts of a presentation, including the background, color, fonts, effects, placeholder sizes, and positioning. The slide master is the largest slide image at the top of the slide thumbnail list. PowerPoint Slide Master Hierarchy. Step 1: Read the PowerPoint templateTo create your custom abstraction layer for PowerPoint, you start by reading in your master template. If you don’t already have one, create a PowerPoint template master slide with slide layouts for each of the different layouts you want to use. In this example, we have the
Tip When you make slide layouts under a master, give each of them a descriptive name that will be easy to use when you are coding later. These names will be used to refer to them within scripts. PowerPoint assigns read-only names to every placeholder within each slide layout. To reveal those read-only names,
create an annotated slide deck using the
This will create the file Step 2: Create the PowerPoint mappingBefore we get to the mapping, take a moment to locate and open the
Within the hierarchy of
Notice, the In the The figure below shows how the annotated layout relates to the Relationship between slide master names, placeholders, and content type and yaml mapping elements. Note: You only have to define mapping information for the slide layouts under a master you want to access in R. You can have as many masters defined in the template as you want and only use a subset in R. Defining markdown defaultsNow you need to define the defaults for rendering components with markdown (see the Workflow vignette for more information on how this is used). For this you need to create elements in the following hierarchy:
For
PowerPoint templates you need to define the sections: Post-processing
Sometimes you may wish to modify the underlying Step 3: Testing and previewing your templateIn R you can read your template by supplying the template and mapping file names:
When a template is read, After reading in the template, you can test the template using
That’s it. You have completed the PowerPoint example and used WordThis section provides a detailed walk-through for each of the three steps in the Introduction. Once again, we recommend everyone walk through this process at least once. In fact, we assume you have already worked through the PowerPoint section. If you have not and don’t feel very comfortable with abstraction layers and yaml syntax, then you might want to walk through that section first. Another quick note about terminology. All Word documents, even a blank document, start from a template. Where PowerPoint templates are more closely tied to specific slide layouts, Word templates are files that help you design documents. They contain content and design elements (referred to as content blocks or styles) to use as a starting point when creating a document. All the formatting is complete; you simply add what you want to them. Step 1: Read the Word documentTo create your
custom abstraction layer for Word, you start by reading in a Word document saved from the template you are using. This Word document should have all the styles defined and contain all the placeholders you want to use. In the Placeholder can be used in documents. For example, if you wanted to use this template for reports, and you wanted to have “Report NNNN”, where NNNN is the report number, in the right header. Then place a text placeholder, e.g., “Report ===RPTNUM===”, in the right header. This placeholder will be referenced in your code; the Creating Templated Office Workflows Vignette has more details. Note: Do not type this placeholder text directly into the Word document. Cut and paste the text into the Word document from a text editor. Word is not a text editor, so while the text string may appear to be contiguous, it may not be so in the underlying XML code. To view all of
the styles in the document you can use the
This will produce a word document, Word layout example. Step 2: Create the Word mappingFor each paragraph, character, and table style, In the
The following sections will walk you through each of these elements in the
|