Giter Club home page Giter Club logo

jlcode's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jlcode's Issues

Single quotes should not be treated as a string

Hey,

Thanks for the package, stellar effort. One small thing I found is that it treats a single quote as a string boundary. This upsets my listings that have matrix transpositions in them (single quote is really a transposition operator in Julia).

I have fixed it myself for now by just removing line 121 from jlcode.sty, but not sure if this is really the right thing to do. Would need a more thorough test set to make sure this does not brake anything.

color of line numbers

I think the color of the line numbers is unfortunately tied to the color of the strings.
It seems to ignore statements like definecolor{jllinenumbers}{HTML}{000000}% % the line numbers of the code block
in the color scheme.
Can one introduce a separate color scheme for line numbers?

\jlinl spacing does not scale with font size

MWE:

\documentclass{article}

\usepackage{listings}

\newlength{\jlinlem}
\settowidth{\jlinlem}{\texttt{m}}
\newcommand{\jlinl}[1]{\lstinline[basicstyle=\ttfamily, basewidth=\jlinlem]^^a7#1^^a7}

\begin{document}
\footnotesize  # NOTE THE SIZE!
bla

 Initialize \jlinl{new_thing()}
\end{document}

Without setting basewidth, this is looks fine:

image

But including it, you get weird spaces:

image

Is there a good reason for setting the basewidth explicitely?

Tens of errors when used with other listings code

Hi, I am using this amazing package but I wanted to also have some JSON code in my paper. I got inspired by this and wanted to use some of the code but whenever I use their code together with jlcode I get up to 60 errors like

Package xcolor: Undefined color jlrule
Package xcolor: Undefined color jlop
Package xcolor: Undefined color jlbase ...

MWE:

\documentclass{article}
\usepackage{bera}% optional: just to have a nice mono-spaced font
\usepackage{listings}
\usepackage{xcolor}

\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}

\lstdefinelanguage{json}{
    basicstyle=\normalfont\ttfamily,
    numbers=left,
    numberstyle=\scriptsize,
    stepnumber=1,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{background},
    literate=
     *{0}{{{\color{numb}0}}}{1}
      {1}{{{\color{numb}1}}}{1}
      {2}{{{\color{numb}2}}}{1}
      {3}{{{\color{numb}3}}}{1}
      {4}{{{\color{numb}4}}}{1}
      {5}{{{\color{numb}5}}}{1}
      {6}{{{\color{numb}6}}}{1}
      {7}{{{\color{numb}7}}}{1}
      {8}{{{\color{numb}8}}}{1}
      {9}{{{\color{numb}9}}}{1}
      {:}{{{\color{punct}{:}}}}{1}
      {,}{{{\color{punct}{,}}}}{1}
      {\{}{{{\color{delim}{\{}}}}{1}
      {\}}{{{\color{delim}{\}}}}}{1}
      {[}{{{\color{delim}{[}}}}{1}
      {]}{{{\color{delim}{]}}}}{1},
}

\begin{document}

\begin{lstlisting}[language=json,firstnumber=1]
{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}
0123456789
\end{lstlisting}

\begin{jllisting}
thisbreaks
\end{jllisting}
\end{document}

I also tried moving the code, removing the \usepackage{xcolor} etc. but nothing helps. Do you know how could I fix this?

\pm problems

Hi, Thank you for your brilliant package I have used it a lot. However, this doesn't work for me (it's the \pm causing the issue):

documentclass[12pt]{article}
\usepackage{jlcode}
\DeclareUnicodeCharacter{00B1}{\textpm}
\begin{document}
	\lstset{frameround=fttt}
	\begin{jllisting}[frame=trBL]
		using Measurements
		θ = 30 ± 5
	\end{jllisting}
\end{document}

I get the error: Invalid UTF-8 byte "B1. θ = 30 ± Note that I have attempted to define the correct unicode character. I am using pdflatex, but I have experimented with lualatex and \usepackage{julia-mono-listings}

Problem with option [usecolors=true]

@wg030 Thanks for this awesome package!

(Not sure if it's an issue or my inexperience with the package functionality.)

I am trying to typeset Julia code without a box but with colors and so in the tex preamble I am using \usepackage[nobox=true,usecolors=true]{jlcode}

In the pdf, there is no box but unfortunately not the colors I expected... all code is gray except numbers (they are red).

Is this caused by interference with (options of) other packages? For example, I am using the xcolor package (but without any options). Any other 'suspicious' packages I should check?

Thanks a lot for any hints and help!

No color in function, for, end, struct

First things first: what an awesome package you have created! Lots of thanks.

Now, my problem:

I'm having trouble displaying the file found in https://github.com/gobenavides/DunklZernikeExpansions/blob/master/src/DunklZernikeExpansions.jl correctly.
More specifically, "function", "for", "end" and "struct" are not appearing boldly.

Since I have plenty of special unicode characters I have to add them manually in the preamble, which I attach entirely in order to be able to track any conflict.

\documentclass[12pt, oneside]{book}
\usepackage[utf8]{inputenc}
\textwidth 17cm
\textheight 22.5cm
\oddsidemargin 0.25cm
\addtolength{\voffset}{-1.5cm}
\addtolength{\hoffset}{-0.5cm}
\usepackage{ragged2e}
\usepackage{fancyhdr}
\usepackage[Sonny]{fncychap}

\ChTitleVar{\LARGE\bf}


\setlength{\parindent}{12pt}
\setlength{\parskip}{3pt}
\usepackage{amssymb,amsmath,epsfig}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{thm-restate}
\usepackage[colorlinks=false,breaklinks=true,linkcolor=blue]{hyperref}
\usepackage{graphics,psfrag,graphicx,color}
\usepackage{float,hhline}
\usepackage{rotating}
\usepackage{diagbox}
\usepackage{setspace}
\usepackage{bibentry}
\nobibliography*

\usepackage{xcolor}
\newcommand{\rednote}[1]{{\color[hsb]{.0,1.0,.75}#1}}
\newenvironment{redarea}{\rednote\bgroup}{\egroup}
\newcommand{\violetnote}[1]{{\color[hsb]{.833,1.0,.55}#1}}
\newenvironment{violetarea}{\violetnote\bgroup}{\egroup}


\usepackage[charsperline=100,usecolors=true]{jlcode}
\addlitjlbase{÷}{\textdiv}{1}
\addlitjlbase{γ1}{$\gamma 1$}{2}
\addlitjlbase{γ2}{$\gamma 2$}{2}
\addlitjlbase{κ1}{$\kappa 1$}{2}
\addlitjlbase{κ2}{$\kappa 2$}{2}
\addlitjlbase{Dunkl–Zernike}{Dunkl--Zernike}{13}

I'm loading my file via \lstinputlisting[breaklines=true,numbers=left]{Julia-code/DunklZernikeExpansions.jl}

I would really appreciate if you help me fixing this issue.

Use with FiraCodeStyle

Hello there! First of all, thanks for sharing the package.

I've been trying to use it in conjuction with the FiraCodeStyle (https://github.com/tonsky/FiraCode/wiki/LaTeX-instructions), because I'd like to display ligatures as well. I cannot make it work, here's what I do:

\setmonofont{Fira Code}[Contextuals=Alternate, Scale=MatchLowercase]
\usepackage[usebox=false, autoload=false]{tex/jlcode}
\usepackage{lstfiracode}
\lstset{language=julia, style=FiraCodeStyle, style=jlcodestyle}

Could you be so kind to check if ligatures remain disabled for you as well?

Unicode box characters for `CodeInfo`

This might be a useful addition for anyone working with Julia internals.

The following definitions, together with pmboxdraw, enable typesetting CodeInfo print-outs:

{┌}{{\ucc{\textSFi}}}{1}
{│}{{\ucc{\textSFxi}}}{1}
{└}{{\ucc{\textSFii}}}{1}
{─}{{\ucc{\textSFx}}}{1}
{┄}{{\ucc{\textSFx}}}{1}

(The triple dash horizontal character is not available in pmboxdraw, but can be replaced by the solid one without confusion, IMO.)

Test case:

1 ── %1  = Base.arraysize(x, 1)::Int64
│    %2  = Base.slt_int(%1, 0)::Bool
│    %3  = Base.ifelse(%2, 0, %1)::Int64
│    %4  = Base.slt_int(%3, 1)::Bool
└───       goto #3 if not %4
2 ──       goto #4
3 ──       goto #4
4 ┄─ %8  = φ (#2 => true, #3 => false)::Bool
│    %9  = φ (#3 => 1)::Int64
│    %10 = φ (#3 => 1)::Int64
│    %11 = Base.not_int(%8)::Bool
└───       goto #22 if not %11

I'd rather typeset those listings without colors, though, since the highlighter obviously gets confused by internal names.

Get utf-8 error with degree symbol

I'm probably just doing something wrong, but can't get the degree symbol to show up. keep getting the latex error of invalid utf-8 byte sequence. Any ideas on how to fix this?

Keep getting Package Listings Error

I think I am doing something wrong, but can't figure out for the life of me why this isn't working.

In the preamble I have :
\let\Bbbk\relax %I get a \Bbbk error if I don't have this before \usepackage[autoload=false]{jlcode}

And then in the document/chapter I have:
\jlinputlisting[language=julia, style=jlcodestyle]{code.jl}
The error I get is
Package Listings Error: File `[(.tex)' not found. \jlinputlisting[

The .jl file was initially in a separate directory so on the off chance it was throwing an error I copied it into the same directory.

Any thoughts on what the issue may be?

FR: Provide environment

Would be nice to have a dedicated environment where one can put code examples in, that gets numbered and can be labeled and referenced

Illegal parameter number in definition of \iterate

First, thanks a lot for the package.
When I try to run the example I get the error Illegal parameter number in definition of \iterate
The package is loading normally, but the error happens when I put the following block:

\begin{jllisting}
  # some julia code
  println( "Here we go with Julia!")
\end{jllisting}

Can someone confirm that the current version is working and the error lies in my side ?

Line breaking is bad

Loving this package.

I am having some issues with ugly linebreaks:
image

The lines break at a point, just not soon enough. This makes me feel like the problem could be fixed.

Avoid clutteting LaTeX project

To use this package, I have uploaded the files from here to my overleaf latex project. This leaves me with the following file structure:
image

Which is a quite horrible mess. Is it possible to make things prettier? If I put everything into a folder, the the paths become wrong. It feels like the paths are defined internally, so that I can not change them without changing the source code.

EDIT: If this IS in fact possible, an example of how to make it happen in the readme would be lovely.

Plenty of error messages involving xcolor

I was not able to run Latex using TexStudio on the following text file without obtaining plenty of error messages involving xcolor. All messages resemble the following one:
Package xcolor Error: Undefined color jlbase'. ...ultDetectionTools, DescriptorSystems, Test`

Here is the contents of the text file:

\documentclass[11pt,a4paper]{article}

% Code blocks definitions: Julia style
% Using https://github.com/wg030/jlcode
% Download the jlcode.sty from that repository 

\usepackage{listings}
\makeatletter
%\usepackage[theme=default]{jlcode}
\usepackage[autoload=true]{jlcode}
%\usepackage{jlcode}
\lstset{%
	language         = Julia,%
	basicstyle       = \small\ttfamily\bfseries,%
	keywordstyle     = \small\bfseries\color{blue},%
	stringstyle      = \small\ttfamily\bfseries,%
    backgroundcolor = \color{white},%
    commentstyle=\small\ttfamily\slshape\bfseries\color{magenta},%
	showstringspaces = false
}
\begin{document}


\begin{jllisting}[frame=lines]
using FaultDetectionTools, DescriptorSystems, Test

# Example 5.4 - Solution of an EFDP
println("Example 5.4")

# define s as an improper transfer function
s = rtf('s');
# define Gu(s), Gd(s), Gf(s)
Gu = [(s+1)/(s-2); (s+2)/(s-3)];     # enter Gu(s)
Gd = [(s-1)/(s+2); 0];               # enter Gd(s)
Gf = [(s+1)/(s-2) 0; (s+2)/(s-3) 1]; # enter Gf(s)
p = 2; mu = 1; md = 1; mf = 2;       # set dimensions

# compute a left nullspace basis Q of [Gu Gd; I 0]
Q1 = glnull(dss([Gu Gd;eye(mu,mu+md)]))[1];

# compute Rf1 = Q1[Gf;0]
Rf1 = gir(Q1*dss([Gf;zeros(mu,mf)]));

# check solvability using a random frequency
if minimum(abs.(evalfr(Rf1,rand()))) > 0.01
   # compute a stable left coprime factorization [Q1 Rf1]=inv(Q3)*[Q,Rf]
   # enforce stability degree -3
   Q_Rf, Q3 = glcf([Q1 Rf1];sdeg = -3);
   # extract Q and Rf
   Q = Q_Rf[:,1:p+mu]; Rf = Q_Rf[:,p+mu+1:end]; 
   scale = evalfr(Rf[1,1],Inf)[1,1]
   Q = Q/scale; Rf = Rf/scale;
   @test gpole(Q) ≈ [-3] && gpole(Rf) ≈ [-3] && fditspec_(Rf) == Bool[1 1] && 
   iszero(Rf - Q*dss([Gf;zeros(mu,mf)]),atol=1.e-7)  && 
   iszero(Q*dss([Gu Gd;eye(mu,mu+md)]),atol=1.e-7)
   # normalize Q and Rf to match example
   println(" Q = $(dss2rm(Q,atol=1.e-7))")
   println(" Rf = $(dss2rm(Rf,atol=1.e-7))")
else
   @info "No solution exists"
end

\end{jllisting}
	
\end{document}

I tried all three alternative ways to load jlcode.sty. The output file looks approximately as expected
Screenshot 2022-10-28 175812

I wonder what I am doing wrong.

interaction with beamer overlays

usually you can specify to show environments on certain beamer overlays with

\begin{env}<2->
\end{env}

for showing that only at the second overlay. However, this doesn't seem to work with jllisting.

Please do not change the typewriter font

Many thanks for this package, which fills an important gap!

However, I don't think it is this package's job to \RequirePackage{courier} and change the typewriter font. I would suggest

diff --git a/jlcode.sty b/jlcode.sty
index afcaaab..c351434 100644
--- a/jlcode.sty
+++ b/jlcode.sty
@@ -28,7 +28,6 @@
   \RequirePackage{textcomp}%
 \fi
 \RequirePackage{calc}
-\RequirePackage{courier}

\jlinl is fragile

\jlinl{Vector{Int}}

gets rendered as ntVectorI, which is a weird effect. (I know that listings' inline verbatim command is sensitive, it surprised me that \jlinl worked so well from the beginning). This can be prevented by escaping the braces:

\jlinl{Vector\{Int\}}

but there should be a warning or something.

Undefined color `jlbase` (xcolor)

Put jlcode.sty in my local package library, using \usepackage{jlcode} in my document.

Get the following error:

Error producing PDF.
! Package xcolor Error: Undefined color `jlbase'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.138   The

xcolor package missing and readme entry about literate

Hi, thanks for all your work.
Your missing a \RequirePackage{xcolor} in your sty.

About your entry in the README.md:

No Support for Special Unicode Characters Yet

You could add a note about using the literate option to display e.g. greek letters.

\lstset{
  extendedchars=true,
  literate={α}{{$\alpha$}}1 {β}{{$\beta$}}1
}

Does not respect linewidth

I frequently have the problem that jlinl text at the end of lines does not break or move, but completely ignores the linewidth:
image

That does not look great, and requires manual fiddling to make right. Would it be possible to fix?

Add $\times$ symbol

I suggest adding

{×}{{\ucc{$\times$}}}{1}

which is useful when converting a Jupyter notebook to LaTeX to properly display output such as

1×3 Array{Float64,2}:
 1.0  2.3  3.14

\approx error

I am working with texstudio\pdflatex and I have the same problem as in #35, i.e. not seeing the \approx in the listing. The error messages I am getting are of the form

Package inputenc Error: Invalid UTF-8 byte sequence. @test gpole(Q) ≈

How to make this work with 2-column documents

hi there, this seems great because it avoids minted and alllows straight-froward upload to arXiv. I'm having trouble with 2-column documents however:

% displayed code
\begin{jllisting}
using DynamicalSystems
# some input data (chaotic Roessler system)
ds = Systems.roessler()
X  = trajectory(ds, 1000.0; Ttr = 1e3)
# Estimate correlation sum
es = estimate_boxsizes(X) # Sect. IV. A
Cs = boxed_correlationsum(X, es; q = 2)
# find and fit linear region
_, Delta = linear_region(log.(es), log.(Cs))
\end{jllisting}

which yields in my setting:

image

Color of functions containing "!"

Functions such as "append!" are not coloured with the "jlfunctions" colour. The text, before the "!" is instead coloured with the "jlbase" colour and the exclamation mark is coloured with the "jlop" colour .

Customize code block length

First of all, thanks a lot for your contributions! It helped me a lot😆

I think customizing code block length maybe better for users, so users can set the size of code block according to their requirements?

Refactor a few keywords in theme

Some of the keywords seem to be hard to read and duplicates information.
For the theme there is theme=dflttheme which doubles theme. What about theme=default? Far better to read and to type.
Similarly

  • theme=dfltthemenobox what is obox? Since that appears again, would it be reasonable to (again) introduce a codebox=true|false?
  • theme=bnwtheme could be theme=blackandwhite? Again the main information of the theme is then not abbreviated
  • theme=bnwthemenobox see above
  • similarly theme=darkthemecould just be theme=dark

Support for LuaLaTeX?

Hello, do you know how to show the math operators when is compiled with LuaLaTeX, since that with pdfLaTeX works well.

\documentclass{scrartcl}

\usepackage[autoload=true]{jlcode}

\begin{document}

Hello Julia

\jlinputlisting{testfile.jl}

\end{document}

Screen Capture_select-area_20201201182744

\documentclass{scrartcl}

\usepackage[autoload=true]{jlcode}

\begin{document}

Hello Julia with Lua\LaTeX.

\jlinputlisting{testfile.jl}

\end{document}

Screen Capture_select-area_20201201183100

1e-12 and 1E-12 wrong color

Numbers are red, but 'e' is green and 'E' is black in "1e-12 and 1E-12". I would like 'e' and 'E' to be part of the number and as so colored red.

Width of the frame

First, thanks a lot for this package.
Otherwise I don't how to print my code with Greek letters.

I found the width of the frame seems fixed to 80 characters.
I would like to suggest making this changeable, because sometimes long lines exist.

Thank you for this great work!

"in" symbol

What's the right place to add

{∈}{{$\in$}}{1}

Thanks.

\ell character

I wasn't really sure in which section to put this, and I have no idea what the number at the end means, so no PR -- but the following works for me:

{ℓ}{{\ucc{$\ell$}}}{1}

Just a thanks

Really like the look you gave this .sty - makes the code look quite pretty! Thanks for making it open source and free.

Kind regards

Please add a license

Unless you specify a license for your code, it is considered proprietary. Usually for LaTeX packages the LPPL is used.

Error in compiling

Errors include:

jlcode.sty:59: Undefined control sequence. [\iftutex]
jlcode.sty:61: Extra \else. [\else]
jlcode.sty:68: Extra \fi. [\fi]

and a lot more

How to increase fonts

Wonderful stuff. I checked in the jlcode.sty file to see if there was an easy way to increase the size of the fonts. In some circumstances, we may need larger fonts, i.e. for slides. But I did not figure out how to do it. How can we increase the fonts' size? Thanks a lot.

xelatex, lualatex

Minor issue: Works brilliantly for pdflatex but not xelatex or lualatex unless I'm doing something wrong. The last two omit subscripts and Greek symbols.

The \approx symbol not working

Hi, I am trying to use the ≈ symbol in my Julia code.

Unfortunately, the symbol doesn't show. I am using this M(not)WE:

\documentclass[a4paper, 12pt]{article}

\usepackage[autoload=false]{jlcode}
\begin{document}

\begin{jllisting}[language=julia, style=jlcodestyle, numbers=left,frame=single,framexleftmargin=2.2em,framexrightmargin=2.2em]
0.0005 ≈ 0.0005000000000001
\end{jllisting}

\end{document}

But the output is only
0.0005 0.0005000000000001

Could you please help me with this issue? I can't see what am I doing wrong. I even found that character defined in the .sty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.