accessible-tex-skeletonizer: Workflow for Establishing Skeleton Accompanying Document from Presentation File
This command line workflow allows a user to quickly set up the skeleton for the "Accompanying Accessibility Document" .tex
file, going from the original .pptx
or .key
presentation slide deck.
In its very basic form, this accompanying document is broken up into sections for each slide, and each section consists of a screenshot/PNG
of the slide and
allows the remediator/accessibility engineer to verbosely describe the contents of the slide, making full use of LaTeX heading (subsection, subsubsection, paragraph, subparagraph), lists, math environments, etc.
The workflow is divided into the following steps:
- Export your slide deck as a directory of individual images.
- Create the text file of your list of titles.
- Prepare the .tex template.
- Render the template and output the skeleton document.
- With your
.pptx
file open, go toFile > Export
which opens a dialogue box. - Select your directory, change the
File Format
option toPNG
, which is the best for LaTeX - Be sure the option for
Save Every Slide
is selected.- This option will save every image as its own
.png
, with the name and numbering schemeSlide1.png
,Slide2.png
, ..., etc. - These slides will be placed in a folder with the name you provide in the
Export As
field.
- This option will save every image as its own
- Click
Export
and after a short while all your slides will be saved as individually named and numbered PNG files.
If working with keynote, it may be easier to simply convert the .key
file into a .pptx
file to facilitate the other steps of this workflow (namely step 2, requiring python-pptx
. However, some elements may not translate well. In which case, it may be useful to export the slide deck into individual images.
- With your
.key
file open, go toFile > Export To... > Images
, which opens a dialogue box. - Select
All
forSlides
,PNG
forFormat
- Once you select
Save
and set your directory, your slide deck will be saved as individual images in a folder with the name and numbering schemepresentation name.001.png
,presentation name.002.png
, ..., etc
In this step, create a .txt
file with the title of each slide on its own line.
Ultimately, this .txt
file will be used to create a Python dictionary which will allow it to autofill a template that helps us set up our document.
To make this step easier, we can use a different Python helper script, pptx_elements_to_list.py that will pull the titles from a .pptx
slide.
Some notes on this titles.txt
file:
- Ensure you have exactly the same number of lines for each slide of your original file.
- Some slides in your original slide title may have not had a title. For the LaTeX Accessibility Doc, it's best if each slide is given a name.
- Repeated slide titles are okay, but it may be useful to have a numbering system (i.e. "Slide Title (1)," "Slide Title (2)," "Slide Title (3)," etc.)
Details in section on accompanying_doc_jinja_template.tex.
Details in section on txt_to_template_rendering.py.
In this version of the workflow, you have to set the graphics path to the directory containing your slide images after rendering the jinja template.
In the preamble (the section before \begin{document}
):
\graphicspath{path to your folder/directory containing the slide images you made in step 1}
Takes a .pptx file, extracts all titles for each slide (if they exist as elements within standard PowerPoint templates), and saves those to a .txt file.
- Python
argparse
andos
(normally included in Python versions >= 2.7)python-pptx
easily installed with pip, installation and documentation here
In command line:
python pptx_elements_to_list.py path/to/file.pptx
Will save a .txt
file in the same directory, with the name file-slide_titles.txt
. You can change the name of the output file with:
python pptx_elements_to_list.py path/to/file.pptx -o my_filename
or python pptx_elements_to_list.py path/to/file.pptx --output_filename my_filename
As of now, the text file will only contain the titles of each slide on a new line. It is adviseable to check the text file to ensure:
- The titles are indeed present as expected.
- If the slide deck was generated without using default master slide templates, and titles were manually added as basic text boxes/shapes,
python-pptx
will not recognize arbitrary text boxes as titles.
- The number of lines equals the number of slides in the original .pptx file.
-
For slides without titles, an empty line will be printed. It is adviseable to add your own title for this slide.
-
Does not seem to work with ppt, so if you have a ppt, it's pretty easy to upconvert to .pptx in PowerPoint "Save As"
This is a specially formatted .tex
file that serves as a template for the rendering Python script. Apart from a few specially formatted lines to work with Jinja,
the file is like any other .tex
file you would create; you can modify this template before or after rendering as you see fit. For example, you may want each section to have a subsection after the image, or a horizontal rule after the image. You can set both of these in the template before rendering to save the work of applying that to every section in your final accompanying document.
In its current configuration, the template will create a new page and a new section named for each title of your text file of title slides. It will place the PNG
of each slide at the top of each page, with a caption and alt text that read "screenshot of slide [title of slide]." You can change this caption and alt text as you see fit, but it is adviseable to keep them the same as each other. The screenshot of the slide will have a box drawn around it, you can modify the appearance of this box with the fbox
settings in the preamble.
-
Of note, you will have to set the graphics path (to the folder containing all images of your slide deck) in the preamble of the LaTeX doc after it renders.
-
There are some quirks with how the rendering is done that mean you should look out for certain symbol combinations. Nested braces
{{}}
is one, which jinja interprets as its own command for a dictionary. This explains the previous point. Another to watch out for is{#
which is the default comment for jinja and will trigger an end of comment error
This is the final Python script you will call to render the .tex
template described above.
- Python (>=3.6)
argparse
andos
(normally included in Python versions >= 2.7)jinja2
easily installed with pip, installation instructions and documentation
python txt_to_template_rendering.py [slide title list text file] [template tex file]
This will output New_Accompanying_Doc.tex
in the same directory, which will be rendered as described in the accompanying_doc_jinja_template.tex
section above.
--output_name
changes the name of the final.tex
file- Image naming format:
- Default is
slide.###.png
padded with leading0
for numbering - Can set prefix and suffixes with
-p=
/--prefix=
and-s=
/--suffix=
- Custom suffixes will allow you to use different image formats as long as they are compatible with LaTeX (i.e. the slides were saved as
.pdf
and not.png
)
- Custom suffixes will allow you to use different image formats as long as they are compatible with LaTeX (i.e. the slides were saved as
- Set number of leading zeros or no leading zeros (default is three digits with leading zeros
001
,002
,003
, etc):--num_format="d"
as a standard integer (1
,2
, etc)--num_format="02"
for two digits with leading zeros (01
,02
,03
, etc)
- Default is