How to (force) pdf conversion of IPython Notebook slides

Introduction

I wrote an entry I want to announce my graduation thesis with IPython Notebook, but the other day the graduation thesis was announced successfully, so I will report it afterwards. I will do it.

In conclusion, the IPython Notebook is great for ** information sharing and program demonstrations in team members and laboratories, but for time-consuming slides such as thesis presentations. The benefit to the effort is small **.

The reason I thought so was as follows.

--Low degree of freedom regarding the placement of figures and the placement of objects --Need to edit the detailed configuration file --Projector resolution, button hiding --You need to execute the command every time you edit and launch the browser. --Automation is possible, but it's more cumbersome than opening a slide file in an editing application --Can only be edited and executed on a PC with an environment (that is, your own) --Difficult to convert to pdf file

Some of the problems have been mentioned in previous articles, so I've solved them, but the fact that the first term is still less flexible can be edited graphically like PowerPoint and KeyNote. Compared to the one, it is inferior. I think it can be a substitute for LaTeX's Beamer (but Beamer has more freedom).

This time, I will introduce a script to alleviate the last part "I have a hard time converting to a pdf file".

How to (force) pdf conversion of IPython Notebook slides

My environment: OS: Ubuntu 14.04 WM: Xmonad 0.11 Required commands: --ʻImport (Package: imagemagick) --convert (package: imagemagick) --xte` (Package: xautomation)

Take screenshots, save them in jpg or png format, and use the convert command to convert those images that have been serialized into a single pdf file.

xte is a command included in a package called xautomation on Ubuntu, which allows you to operate the keyboard and mouse from the shell. is. Use this feature to automate the action of taking screenshots, freeing you from the hassle. Besides, it feels good to see the screen move without doing anything.

Below is a simple script I created. Please read in your own environment.

#!/bin/bash

folder=$(pwd)
num=40
xte 'keydown Super_L' 'key 4' 'keyup Super_L'
for t in `seq 1 ${num}`
do
    name=$(printf screen_%03d.jpg $t);
    sleep 0.5
    import -window root -quality 0 ${folder}/${name}
    xte 'key Right'
done
xte 'keydown Super_L' 'key 3' 'keyup Super_L'
exit 0

How to use

Match the resolution of your monitor to the resolution of your projector in advance. xrandr --output HDMI1 --mode 1024x768 Etc.

Then, in another workspace, enter Notebook's slide mode and keep it full screen (to take a screenshot of this entire screen).

The image is saved in the directory when the script is called, so it is better to call the script from the newly created directory. Change num according to the number of slides. The next line of operations using xte will take you to the workspace where your browser is running. Those who move with the arrow keys should rewrite as such.

When you run the script, you'll be taken to workspace 4 where you're viewing the slide, take a full-screen screenshot without compression with the ʻimport` command, and press the → key to move to the next slide (Page Down to Sub slide Can also be included). Repeat this and return to workspace 3 when you have taken the specified number of shots.

After taking the slides, delete unnecessary slides and check if they are in pdf order.

convert -page 1024x768 -gravity Center *.jpg out1.pdf

Make a pdf file like this.

Summary

In my case, I was able to make a presentation in Notebook, but no one was skeptical about that point, and I was asked questions about my research. It's a little lonely, but of course. The pdf version of the material is often used for presentations in the laboratory, so there may still be opportunities to use it. However, I think it's better to make slides with Impress of LibreOffice obediently. I think it's a good idea to use Notebook as a draft for yourself and as a tutorial for the program.

Recommended Posts

How to (force) pdf conversion of IPython Notebook slides
[IPython] How to Share IPython Notebook
How to use IPython Notebook
Jupyter Notebook Basics of how to use
How to revive cells in iPython notebook
How to debug with Jupyter or iPython Notebook
How to use IPython
How to use Jupyter Notebook
How to import NoteBook as a module in Jupyter (IPython)
How to see the contents of the Jupyter notebook ipynb file
How to import NoteBook as a module in Jupyter (IPython)
Summary of how to use pandas.DataFrame.loc
Conversion from pdf to txt 1 [pdfminer]
Summary of how to use pyenv-virtualenv
Summary of how to use csvkit
[Python] Summary of how to use pandas
How to speed up instantiation of BeautifulSoup
How to get rid of long comprehensions
How to check the version of Django
How to install CatBoost [as of January 2020]
How to calculate Use% of df command
How to execute commands in jupyter notebook
[Python2.7] Summary of how to use unittest
How to use jupyter notebook with ABCI
Basics of PyTorch (1) -How to use Tensor-
How to use the IPython debugger (ipdb)
Summary of how to use Python list
[Python2.7] Summary of how to use subprocess
How to use Jupyter notebook [Super Basic]
Summary of how to write AWS Lambda
[Question] How to use plot_surface of python
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
How to make the font width of jupyter notebook put in pyenv equal width
How to calculate the volatility of a brand
A simple example of how to use ArgumentParser
How to find the area of the Voronoi diagram
[Python] How to use two types of type ()
How to keep track of work in Powershell
Summary of how to import files in Python 3
Not much mention of how to use Pickle
Summary of how to use MNIST in Python
How to convert SVG to PDF and PNG [Python]
How to specify attributes with Mock of python
How to implement "named_scope" of RubyOnRails with Django
How to get dictionary type elements of Python 2.7
Batch conversion of Excel files to JSON [Python]
[Java] How to switch between multiple versions of Java
Introducing Spark to EC2 and linking iPython Notebook
How to force build TensorFlow 2.3.0 for CUDA11 + cuDNN8
Create a table of contents with IPython notebook