2

I'm trying to import a complete code file into a lyx document using the minted package. But the resulting document has no code at all. Here is a minimal example.

And there's nothing in the resulting pdf file.

The file hi.java exists and contains a Hello world program.

resulting pdf

LyX file:

#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass heb-article
\begin_preamble
\usepackage{fullpage}
\usepackage{adjustbox}
\usepackage{minted}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language hebrew
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\float_placement H
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\index אינדקס
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard

\size largest
הרעיון הבסיסי של
\family roman
\series medium
\shape up
\emph off
\bar no
\strikeout off
\uuline off
\uwave off
\noun off
\color none

\family default
\series default
\shape default
\emph default
\bar default
\strikeout default
\uuline default
\uwave default
\noun default
\color inherit
\lang english
LyX
\lang hebrew
 הוא שאין צורך לטפל בעיצוב.
 ישנה רשימה של עיצובים קיימים וניתן לבחור מתוכה את אופי הטקסט (כותרת ראשית,
 כותרת משנית, הערת שוליים וכו').
 כך, התוצאה הסופית אמורה להיות עקבית ובעלת מראה מקצועי.

\begin_inset Newline newline
\end_inset


\size default

\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
inputminted{java}{hi.java}
\end_layout

\end_inset


\end_layout

\begin_layout Standard

\size largest
בנוסף, מאפשר 
\lang english
LyX
\lang hebrew
 כתיבה נוחה של משוואות מתמטיות ולכן נפוץ בקרב קהילת האקדמאים העוסקים במדעים
 מדויקים.
\end_layout

\end_body
\end_document

Exported TeX file:

%% LyX 2.1.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9,cp1255]{inputenc}
\usepackage{float}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

% The following chunk fixes export with XeTeX.
% It is needed because polyglossia is used by default
% and \make@lr is only defined by babel.
\@ifundefined{make@lr}
{\def\make@lr#1{\begingroup
    \toks@=\expandafter{#1}%
    \edef\x{\endgroup
  \def\noexpand#1{\noexpand\@number{\the\toks@}}}%
  \x}}{\relax}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{fullpage}
\usepackage{adjustbox}
\usepackage{minted}

\makeatother

\usepackage{babel}
\begin{document}
{\LARGE{}הרעיון הבסיסי של }\inputencoding{latin9}\L{{\LARGE{}\LyX{}}}\inputencoding{cp1255}{\LARGE{}
הוא שאין צורך לטפל בעיצוב. ישנה רשימה של עיצובים קיימים וניתן לבחור
מתוכה את אופי הטקסט (כותרת ראשית, כותרת משנית, הערת שוליים וכו').
כך, התוצאה הסופית אמורה להיות עקבית ובעלת מראה מקצועי. }\\
\inputminted{java}{hi.java}

{\LARGE{}בנוסף, מאפשר }\inputencoding{latin9}\L{{\LARGE{}\LyX{}}}\inputencoding{cp1255}{\LARGE{}
כתיבה נוחה של משוואות מתמטיות ולכן נפוץ בקרב קהילת האקדמאים העוסקים
במדעים מדויקים.}
\end{document}

hi.java contents:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}
3
  • Does passing the full path of hi.java help? – scottkosty Jun 25 '15 at 20:20
  • @scottkosty WOW that was so silly of me I've added the full path using / on windows and it worked, it's still reversed (as stated in my other question so if you have another awesome simple solution it'd be great) but it's a start please post as an answer so I can accept. – Darius Jun 25 '15 at 20:28
  • well actually it's not that silly of you. Ideally relative paths should work, but since LyX uses a temporary directory and does not know about the java file (because you're using ERT) it doesn't know to copy it to the temporary directory. An alternative might be to change the temporary directory to be the current directory (setting the path as . works on Ubuntu but I don't know about Windows). – scottkosty Jun 25 '15 at 20:31
1

Probably 2 solutions:

  1. Specify the full (absolute path).
  2. Make the current directory the working directory. To do this go to Tools > Preferences > Paths and under temporary directory put .. This works on Ubuntu but I'm not sure about Windows.

Explanation: because you are using ERT, LyX does not know to copy the file to the temporary directory that it uses to compile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.