0

Following this question I was able to insert (Java) code into my lyx document. However, when I try to visualize (export it as a .pdf) the following error comes up:

I can't work with sizes bigger than about 19 feet. Continue and I'll use the largest value I can.

The related questions I found, this one and this one are related to including images into a document. Why does lyx show the same error when working with code snippets?

The issue appears in the following case:

long code 1

The error message:

long code 2

A shortened example can be found here

Sebi
  • 392
  • 1
    Can you please post a minimal example? see http://wiki.lyx.org/FAQ/MinimalExample – scottkosty Jan 18 '16 at 17:54
  • I actually found out why. When copy/pasting from Intellij the white spaces are discarded and the code appears to lyx to be a very long string that it doesn't like. – Sebi Jan 18 '16 at 18:12
  • @scottkosty No, I was wrong, I'm updating the question. I cannot really post a minimal example since the error occurs when the code to be inserted is of a certain length. – Sebi Jan 18 '16 at 18:21
  • I see. Are you able to upload an example to dropbox or google drive or somewhere else? – scottkosty Jan 18 '16 at 18:24
  • Yes, I'm adding the document now. – Sebi Jan 18 '16 at 18:41
  • @scottkosty Added it now. – Sebi Jan 18 '16 at 18:42
  • For me the example you posted compiles fine to PDF. – scottkosty Jan 18 '16 at 19:06
  • Yes, it does compile but the lines do not split accordingly. I mean my code is hafway outside the page. – Sebi Jan 18 '16 at 19:07
  • Ah yes I can reproduce but in your question you say you get errors. Is this a separate question? – scottkosty Jan 18 '16 at 19:39
  • I get errors when I have lines that are too long. – Sebi Jan 18 '16 at 20:17
  • @scottkosty nvm I've fixed it using the smallest available font size, adding new lines after each line of code and shortening each line to about 100 characters and have also checked the Break long lines options in the Settings menu. – Sebi Jan 18 '16 at 20:19
  • 1
    OK please add an answer to this question and accept it. Glad you got it figured out! – scottkosty Jan 18 '16 at 20:41
  • You seriously want some kind of automatic line breaks added to your code. – Martin Schröder Jan 20 '16 at 09:33
  • No. I mean you can't break up code and still expect it to run (definitions method contracts and invocations may be affected). The initial version did not display the lines at all once they reached the right margin of the page. – Sebi Jan 20 '16 at 10:51

1 Answers1

2

I've managed to fix it by splitting all lines of code with new lines (when copied from intellij all '\n' characters have been removed and this cause a problem as the source was too long). Then, by right clicking the source code("Program listing") and going to the "Settings" I've changed the following:

  • in the Style menu box picked smallest font type (not tiny)
  • changed the family type to "Roman"
  • checked the break long lines box

It is important that each line has no more than 100 characters, otherwise when converting to .pdf (luatex) the lines might not fit within the pages of the exported .pdf.

Sebi
  • 392