On Thu, Jan 13, 2022 at 10:07 PM Dr Eberhard Lisse via lyx-users <
lyx-users@lists.lyx.org> wrote:

> Joe,
>
> When you open the Insert -> File -> Child Document -> Program Listing
> there should be a window looking something like the enclosed, where you
> can either type the path to the file (complete or relative as in this
> example) or click the Browse button, find the file and double click it
> after the path will appear there.
>
> Please note the Caption, Label and the parameters.  If you enter
> something on the right the left will show you "completions" and/or
> choices. Color is mentioned in the LaTeX Listings manual.
>
> greetings, el
>
> On 2022-01-14 05:32 , Joseph Hesse via lyx-users wrote:
> > On 1/13/22 21:11, Herbert Voss wrote:
> >> Joseph Hesse via lyx-users schrieb:
> >>> On 1/12/22 15:00, Herbert Voss via lyx-users wrote:
> >>>> Use /Insert -> Program Listing/ option.
> >>>>
> >>> I tried what you suggested.  I right clicked on the inset and could
> >>> not find an option where I could specify where my code listing are
> >>> located.
> >>
> >> What do you mean with "listing are located"?  If you do not define it
> >> as a float it will appear at the place where you defined it.
> >>
> >> Attached the screenshot of the output of the demo file.
> >>
> >> Herbert
> > I am sorry that I did not state my problem more clearly.
> > Before even using lyx, I have program code in folders in my computer.
> > I want to have this code appear in my lyx document.  What I meant was
> > that when I use "Insert -> Program Listing" I do no see a way to
> > choose the folders on my computer to import these already written
> > programs into my lyx document.  The only option that gave me that
> > choice was "Insert -> File -> Child Document" and this seems to work
> > for me except for the color.
> > Thank you,
> > Joe
> > --
> lyx-users mailing list
> lyx-users@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-users


With respect to concrete styling, below my signature is an example snippet
that I use (or some variation thereof) in my preamble for code listings via
the listings package.  I hope it helps.

As EL noted, one can then use the LyX dialog to specify
language=<something> to perform syntax highlighting.

Thank you,
Joel

--

\usepackage{xcolor}

\definecolor{UMBlue}{HTML}{00274C}
\definecolor{UMMaize}{HTML}{FFCB05}
\definecolor{UMTappanRed}{HTML}{9A3324}
\definecolor{UMRossOrange}{HTML}{D86018}
\definecolor{UMRackhamGreen}{HTML}{75988d}
\definecolor{UMWaveFieldGreen}{HTML}{A5A508}
\definecolor{UMTaubmanTeal}{HTML}{00B2A9}
\definecolor{UMArboretumBlue}{HTML}{2F65A7}
\definecolor{UMA2Amethyst}{HTML}{702082}
\definecolor{UMMatthaeiViolet}{HTML}{575294}
\definecolor{UMUMMATan}{HTML}{CFC096}
\definecolor{UMBurtonTowerBeige}{HTML}{9B9A6D}
\definecolor{UMAngellHallAsh}{HTML}{989C97}
\definecolor{UMLawQuadStone}{HTML}{655A52}
\definecolor{UMPumaBlack}{HTML}{131516}

\colorlet{CodeComment}{UMRossOrange}
\colorlet{CodeLineNumber}{UMAngellHallAsh}
\colorlet{CodeString}{UMA2Amethyst}
\colorlet{CodeBackground}{white}
\colorlet{CodeKeyword}{UMArboretumBlue}

\lstset{
  backgroundcolor=\color{CodeBackground},        % choose the background
color; you must add \usepackage{color} or \usepackage{xcolor}
  basicstyle=\normalsize\ttfamily,               % the size of the fonts
that are used for the code
  breakatwhitespace=false,                       % sets if automatic breaks
should only happen at whitespace
  breaklines=true,                               % sets automatic line
breaking
  captionpos=t,                                  % sets the
caption-position to bottom
  commentstyle=\color{CodeComment},              % comment style
  deletekeywords={...},                          % if you want to delete
keywords from the given language
  escapeinside={\%*}{*)},                        % if you want to add LaTeX
within your code
  extendedchars=true,                            % lets you use non-ASCII
characters; for 8-bits encodings only, does not work with UTF-8
  frame=single,                                  % surround with a black
line
  keywordstyle=\color{CodeKeyword},              % keyword style
  keepspaces=true,                               % keeps spaces in text,
useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},                     % keyword style
  morekeywords={*,...},                          % if you want to add more
keywords to the set
  numbers=left,                                  % where to put the
line-numbers; possible values are (none, left, right)
  numbersep=5pt,                                 % how far the line-numbers
are from the code
  numberstyle=\scriptsize\color{CodeLineNumber}, % the style that is used
for the line-numbers
  stepnumber=1,                                  % the step between two
line-numbers. If it's 1, each line will be numbered
  showspaces=false,                              % show spaces everywhere
adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,                        % underline spaces within
strings only
  showtabs=false,                                % show tabs within strings
adding particular underscores
  stringstyle=\color{CodeString},                % string literal style
  tabsize=2,                                     % sets default tabsize to
2 spaces
  title=\lstname,                                % show the filename of
files included with \lstinputlisting; also try caption instead of title
}
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to