# PDF output size changed after system/Lyx upgrade (pdflatex)

In the last few months, I upgraded my system (Debian) from Jessie to Stretch. I suspect that the LaTeX and other packages have been updated, too. I use Lyx.

My novel was formatted in Lyx 2.1 and now I'm using Lyx 2.2.2. Since I've reopened my original Lyx file, the PDF output has changed from 140 x 266mm to 216 x 276mm (US Letter), without me editing any of the settings. I'm using pdflatex to output the files, so didn't alter that. However the latex log now shows this error:

Package geometry Warning: The marginal notes overrun the paper.
Add 98.865pt and more to the right margin.


If I output from Lyx using ps2pdf, it comes out the correct size. Obviously, I didn't want to have to switch the output to ps2pdf, since pdflatex used to work fine, and it concerns me as to why the output doesn't work correctly anymore.

I'm using the memoir module to format my novel, and as I've discovered in other questions, this may now conflict with geometry (which Lyx automatically sets up).

Is this a known issue/bug, and if I need to provide more information to find out what's happening, what do I need to provide?

Here's a pastebin to a non-working (erroneous) file: https://pastebin.com/ZepvZ9aV And a basic svg to embed in the place of the files used: https://pastebin.com/u0Zq0hPG

I have determined that the SVGs and PNG referenced in the file are the cause. If deleted, the file will render at the correct size. I need the images in the file, so it's simply a case of working out whether there's a bug somewhere, or if it's a combination of software packages on my system.

Inkscape 0.92.1 r15371

Build info in Lyx:

LyX 2.2.2 (2016-10-10)
Git commit hash
Configuration
Host type:               x86_64-pc-linux-gnu
Special build flags:      build=release warnings c++11 std-regex use-enchant
C++ Compiler:            g++ (6.2.1)
C++ Compiler flags:       -Wall -Wextra -std=c++11 -fPIC -O2 -Wno-deprecated-declarations
C++ Compiler user flags: -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/lyx-2.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC
Linker user flags:       -Wl,-z,defs -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
Qt Frontend:
Qt version:      5.7.1
Packaging:               posix
LyX binary dir:          /usr/bin
LyX files dir:           /usr/share/lyx


pdflatex: This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex)

The difference between the original (working) file and the newly saved incorrect file are as follows:

--- /original.lyx
+++ /modified.lyx
@@ -1,7 +1,9 @@
-#LyX 2.1 created this file. For more info see
-\lyxformat 474
+#LyX 2.2 created this file. For more info see
+\lyxformat 508
\begin_document
+\save_transient_properties true
+\origin unavailable
\textclass memoir
\begin_preamble
\usepackage{microtype} % reduce amount of unnecessary and broken hyphenation
@@ -47,18 +49,18 @@
\language_package default
\inputencoding auto
\fontencoding global
-\font_roman charter
-\font_sans default
-\font_typewriter default
-\font_math auto
+\font_roman "charter" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "default"
+\font_math "auto" "auto"
\font_default_family rmdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
-\font_sf_scale 100
-\font_tt_scale 100
+\font_sf_scale 100 100
+\font_tt_scale 100 100
\graphics default
-\default_output_format default
+\default_output_format pdf
\output_sync 0
\bibtex_command default
\index_command default
@@ -331,7 +333,8 @@
\begin_inset Newline newline
\end_inset

-Typeset in Bitstream Charter 10pt using LaTeX
+Typeset in Bitstream Charter 10pt using \SpecialChar LaTeX
+
\end_layout

\begin_layout Standard
@@ -376,6 +379,10 @@

\end_layout

+\end_inset
+
+
+\begin_inset Separator latexpar
\end_inset

@@ -1615,6 +1622,10 @@
\end_inset

+\begin_inset Separator latexpar
+\end_inset
+
+
\end_layout

\begin_layout Standard


Edit (SOLVED) I never resolved the issue with Lyx, but it seems to be caused by newer versions of geometry and memoir being less forgiving. Whilst old versions generated the file correctly (but with errors) the newer versions resize the page to fit. I have ended up abandoning Lyx for editing my novel and instead written the file by hand and recalculated the page dimensions, then used only memoir's margin/size settings to determine layout and dropping the geometry package from the file.

• I don't think it is known. If you can post a minimal example .lyx file that used to work well, then I can take a look and tell you whether the issue is due to LyX or to the TeX Live upgrade. – scottkosty Oct 7 '17 at 14:54
• Thanks, I'll try to put a file together over the weekend. – Rexx Magnus Oct 7 '17 at 17:16
• OK, when you update your question with the minimal example, notify me with the @ sign followed by my username. Otherwise I won't be notified that you are directing a comment at me. – scottkosty Oct 7 '17 at 17:17
• @scottkosty - so it looks like it's the images. I've put up a pastebin to the document and also to a sample svg. – Rexx Magnus Oct 7 '17 at 18:04
• can you post a "good" PDF (how you want it to look and how it used to look) and "bad" PDF (how it looks on your new system)? Do that using the example SVG file, that way I can compare the results when I take a look. – scottkosty Oct 7 '17 at 18:16

Solution: tell LyX to use inkscape to convert the SVG files instead of rsvg-convert:

1. Go to Tools > Preferences > Converters.

2. Select "SVG -> EPS", and for "Converters" change it to:

inkscape --file=$$i --export-area-drawing --without-gui --export-eps=$$o

3. Click on "Modify".

4. Click on "Save".

Now do the same but for "SVG -> PDF":

1. Go to Tools > Preferences > Converters.

2. Select "SVG -> PDF", and for "Converters" change it to:

inkscape --file=$$i --export-area-drawing --without-gui --export-pdf=$$o

3. Click on "Modify".

4. Click on "Save".

The output of PDF (pdflatex) should now be the same as it used to be for you.

rsvg-convert appears to be preferred over inkscape (i.e. if both are available, rsvg-convert is used) since it is faster. See also this ticket for more information.

• So it seems I never got to truly fix the issue in Lyx. Apparently there's a conflict between newer versions of the geometry and memoir packages that are less forgiving. Older versions generate the error, but still produce the pdf correctly, whilst the latest versions resize the page accordingly. My only solution was to abandon Lyx (I never really liked using it, anyway) and then drop the geometry package and recalculate my margins using the memoir settings only. – Rexx Magnus Oct 15 '17 at 15:06
• That is an annoying issue. I'm glad you figured out a workaround (and as a bonus switched to a tool that you prefer). – scottkosty Oct 15 '17 at 17:03

(not really an answer, more like a long comment)

The root difference comes down to the different graphics backends of latex and pdflatex. LyX knows to convert the .svg file to a .pdf when compiling with pdflatex, and to a .eps when compiling with latex. Here is a "non-LyX MWE" (created after LyX does the image conversions in the background) that shows the differences: mwe.tar.gz. The different PDFs can be created using the following commands:

latex mwe.tex && dvips mwe.dvi && ps2pdf mwe.ps && mv mwe.pdf mwe_latex.pdf
pdflatex mwe.tex && mv mwe.pdf mwe_pdflatex.pdf


You might consider posting a new question with this non-LyX MWE, so that the experts around here can take a look.

LyX could still be to blame for the problem. For example, LyX uses a command to convert the .svg to .pdf and .eps. If LyX is using an incorrect command, that could explain the problem. However, I have tested with LyX versions back to 2.1.0 and I can still reproduce the differences. So if you're seeing a change of behavior, my guess is that it is due to either an updated TeX system, or to the external tool that LyX is using to convert (inkscape in this case).

Note that using rsvg-convert, instead of inkscape, to convert the .svg file to .pdf and .eps leads to the same issue. This makes me think that a change in inkscape (e.g. when you upgraded your system) is not likely to explain the issue.

• I just tested that minimal example you posted, and both rendered exactly the same size (US letter, 216x279mm). I guess I need to try cutting the lyx file down or generating the tex file and trying the commands above with that to see if that makes a difference. – Rexx Magnus Oct 8 '17 at 18:25
• Interesting, the mystery grows. I just double-checked and I indeed get different outputs for mwe_latex.pdf and mwe_pdflatex.pdf when I run the commands I posted above on the MWE I posted. Your strategy sounds good so that you can produce a non-LyX MWE. – scottkosty Oct 8 '17 at 18:49
• I know this isn't terribly helpful, but I'm not sure of the best way to go about generating the .tex file - it seems Lyx has several options (XeTex, pdflatex, plain, LuaTex, dviluatex) - they seem to spit out slightly different things in the file when it comes to the line: \usepackage[latin9]{inputenc} I'm guessing the output from each command simply generates pdfs/eps etc. from any included graphics. – Rexx Magnus Oct 8 '17 at 19:26
• Try this: view in LyX, then go to Document > LaTeX Log and click on "Open Containing Directory". does that help? – scottkosty Oct 8 '17 at 19:29
• It does a little. The main difference I can now see with the exports vs the generated is a short preamble at the beginning: \batchmode \makeatletter \def\input@path{{/path/to/folder/}} \makeatother – Rexx Magnus Oct 8 '17 at 19:41