From 44c391cb5a0cb6ce35ab54f3abe886de18f55c66 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Sun, 9 Apr 2017 11:04:24 +0200 Subject: [PATCH 1/2] Better renaming of the images to keep files in temp dir. --- contrib/pdf_slideshow.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/contrib/pdf_slideshow.lua b/contrib/pdf_slideshow.lua index bfcdedc..3f332eb 100644 --- a/contrib/pdf_slideshow.lua +++ b/contrib/pdf_slideshow.lua @@ -123,6 +123,13 @@ local function my_write(latexfile,arg) end end +local function img_filename(file,i) + local dir=string.gsub(file, "(.*)(%/.*%..*)", "%1") + local ext=string.gsub(file, "(.*)(%..*)", "%2") + local lfile = dir.."/slide"..i..ext + return lfile +end + local function slide(latexfile,i,image,file) local title = "" if title_widget.text ~= "" then @@ -146,17 +153,12 @@ local function slide(latexfile,i,image,file) title = string.gsub(title, "\r", "") title = string.gsub(title, "\t", "") - local lfile = "slide"..i..".jpg" + local lfile = img_filename(file,i) os.rename(file, lfile) - -- fact is that latex will get confused if the filename has multiple dots. - -- so \includegraphics{file.01.jpg} wont work. We need to output the filename - -- and extention separated, e.g: \includegraphics{{file.01}.jpg} - local filenoext=string.gsub(lfile, "(.*)(%..*)", "%1") - local ext=string.gsub(lfile, "(.*)(%..*)", "%2") my_write(latexfile,"\\begin{minipage}[b]{0,99\\textwidth}\n") - my_write(latexfile,"\\includegraphics[height=0.95\\textheight]{{"..filenoext.."}"..ext.."}\\newline\n") + my_write(latexfile,"\\includegraphics[height=0.95\\textheight]{"..lfile.."}\\newline\n") my_write(latexfile,"\\centering{{\\color{white}\\verb|"..title.."|}}\n") my_write(latexfile,"\\end{minipage}\\quad\n") end @@ -229,7 +231,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), -- finally do some clean-up local i = 1 for img,file in pairs(image_table) do - local lfile = "slide"..i..".jpg" + local lfile = img_filename(file,i) os.remove(lfile) i = i+1 end From 9a6c1510fdc7e3decd7d6bb16e705c9c7caeb4de Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Sun, 9 Apr 2017 18:46:21 +0200 Subject: [PATCH 2/2] Another change to get better output. This changeset gives better output for portrait and landscape pictures. Now in both cases the image is properly center on the screen. --- contrib/pdf_slideshow.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/pdf_slideshow.lua b/contrib/pdf_slideshow.lua index 3f332eb..0b68417 100644 --- a/contrib/pdf_slideshow.lua +++ b/contrib/pdf_slideshow.lua @@ -156,11 +156,12 @@ local function slide(latexfile,i,image,file) local lfile = img_filename(file,i) os.rename(file, lfile) - my_write(latexfile,"\\begin{minipage}[b]{0,99\\textwidth}\n") - - my_write(latexfile,"\\includegraphics[height=0.95\\textheight]{"..lfile.."}\\newline\n") - my_write(latexfile,"\\centering{{\\color{white}\\verb|"..title.."|}}\n") - my_write(latexfile,"\\end{minipage}\\quad\n") + my_write(latexfile,"\\begin{figure}\n") + my_write(latexfile,"\\begin{measuredfigure}\n") + my_write(latexfile,"\\includegraphics[height=0.92\\textheight]{"..lfile.."}\n") + my_write(latexfile,"\\end{measuredfigure}\n") + my_write(latexfile,"\\caption{{\\color{white}"..title.."}}\n") + my_write(latexfile,"\\end{figure}\n") end dt.register_storage("pdf_slideshow",_("pdf slideshow"), @@ -168,10 +169,11 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), function(storage,image_table) local preamble = [[ - \documentclass[a4paper,10pt,landscape]{beamer} + \documentclass[a4paper,12pt,landscape]{beamer} \usetheme{default} \usepackage[utf8]{inputenc} \usepackage{graphicx} + \usepackage{threeparttable} \usepackage[space]{grffile} % needed to support filename with spaces \pagestyle{empty} \parindent0pt @@ -179,7 +181,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), \usepackage{color} \pagecolor{black!100} \color{white} - \geometry{a4paper,landscape,left=5mm,right=5mm, top=5mm, bottom=5mm} + \geometry{a4paper,landscape,left=2mm,right=2mm, top=2mm, bottom=2mm} \mode \transduration{]]..delay_widget.value..[[} \setbeamertemplate{footline}{} @@ -189,6 +191,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"), \setbeamercolor{background canvas}{fg=white,bg=black!100} \setbeamercolor{normal text}{fg=white} \hypersetup{pdfstartpage=1,pdfpagemode=FullScreen} + \setbeamertemplate{caption}{\insertcaption} \begin{document} ]]