Texments package not working on Ubuntu - latex

I am trying to use the Texments Latex package on Ubuntu to do syntax highlighting.
Texments is a wrapper around Pygments.
I installed Texments and followed the steps to add the style file to the path.
But when I try to compile the .tex file, I get the error.
!Undefined Control Sequence
and then it prints out a bunch of wierd characters and places the ? prompt.
Anybody facing this error? What is the resolution?
If there is any other better way to provide syntax highlighting of source code I would be glad to accept it.
I know there is something called "listings" but frankly, i did not find the colors so good in it.
Thanks,

Perhaps you could give minted a try … it basically does the same as texments but has more features and is a little more robust in the face of errors.
Furthermore, as the maintainer of minted I’m always glad of error reports. ;-)

Texments uses a special control sequence for pdftex to allow shell escapes, needed to call the pygmentize binary. You need to call it with pdflatex, and you need to pass pdflatex the -shell-escape switch. Cf. the texments documentation.

Related

After I've updated Latex, why I still get an error?

I am using MacTex on my Mac and try to us Texmaker as my editor.
However, when I type \usepackage{algorithms} in Texmaker, it always warn me that algorithms.sty is not found. I also tried this in Texshop, the error was the same.
I firstly checked TexLive Utility to make sure algorithms package is installed. It gives an yes. Then I tried to copy algorithms.sty from /usr/local/texlive/2015/texmf-dist/tex/latex/algorithms folder to /usr/local/texlive/2015/texmf-dist/tex/latex/base folder and execute texhash to update. Still not working and get the same error.
Can someone help me with this? Any help is appreciated.
algorithms is actually a bundle that provides two separate *packages":
algorithm
Provides the algorithm float and float-associated accessories.
algorithmic
A environment that provides a layout of algorithm pseudo-code.
So, to use algorithms, you need either or both of
\usepackage{algorithm}
\usepackage{algorithmic}

could not start the command pdflatex - synctex=1 -interaction=nonstopmode %.tex error

I'm very new to LaTeX and its distributions so this might be a very newbie question.
I was following this tutorial and I'm not being able to compile the document. The code so far is very simple i don't think there are any typos and also I did not find a similar question in the forum.
can someone point me in the right direction ?
I'm using windows XP and I've installed TexMaker 4.4.1 found here
The code I have so far is simply:
\documentclass[11pt]{article}
\begin{document}
This is my first LaTeX document.
\end{document}
the error I'm getting is:
Could not start the command. pdflatex -synctex=1
-interaction=nonstopmode %.tex
Cheers !
If you meet the error:
Error : could not start the command
while executing TexMakerX commands in Windows 7 x64, it is probably due to environment path of LaTex compiler.
The following steps may help you solve this error:
Make sure that you did install a LaTex compiler like MiKTeX. You know, TexMakerX is just an editor of latex input, not a compiler.
Locate the bin directory in the installation directory of the LaTex compiler.
Add the directory of bin like d:\Program Files (x86)\MiKTeX 2.9\miktex\bin to the environment paths of Windows.
Right click computer in start menu, choose properties.
Find the "Advanced system settings" in upper left corner.
Click the button "Environment Variables".
Find the row of variable path in the group of "System Variables" and add bin path like ;d:\Program Files (x86)\MiKTeX 2.9\miktex\bin to the tail.
Remember to add a semicolon to separate different path.
Then, try it again...
I found this question on another forum and it says that you should install MiKTex for windows too. Worked like a charm !
I came across a page which mentions that MiKTeX has two major bugs due to which users haven't been able to compile at all.
Use TeX Live compiler instead
Source
https://wiki.lyx.org/Windows/TeXLive
Most of the time errors occur due to space in the file names. while saving the Latex file one should always remember don't put spaces in between the file name.

Add gcc error text parsing to Kate?

It seems an obvious improvement, in Kate, to jump directly to the error location given in a gcc error message. It would great if it can be made to work directly in Kate's terminal, but I would settle for a tool that can yank text off the x clipboard. Failing that, is there a way to write an add-on for Kate to do this?
Thanks.
Mike.
from the terminal we can run something like this:
$ kate source.cpp --line=45
you could write a script to parse gcc output and re-open kate to that line in the source. If kate already has the source code open, it will simply emulate a jump to the line.
There is "Build" plugin for Kate, which does also stderr parsing, and understand GCC error syntax.
So for example you can easily configure in Kate to build your project with make (and KDevelop is sharing this part of Kate source and plugin, although KDevelop has extra plugins for project management), and you will see in the Build plugin output parsed errors, clicking on them will direct you to the particular source file and line.
(but I was just looking around if it can even mark the error lines in the source visually, and actually there's nothing like it? From my limited understanding of the Kate plugin API I would be slightly afraid this is not trivial to add to current Build plugin, but I didn't dig into the Kate sources enough to fully understand its architecture and what are the true limits for plugin code).

How to print Smalltalk code from Pharo/Squeak?

What is the best way to print - syntax colored and well formatted - code from Pharo/Squeak on paper?
1) Is there a way to print directly from within Pharo/Squeak? (i use it on macosx)
2) Is there a way to export syntax colored, well formatted code from Pharo/Squak?
3) Are there external tools to color and format a filed out piece of code?
For the appendix in my master thesis I used the Pier CMS-to-LaTeX converter in the Pier-Documentation package. However, this plugin only takes class comments and method comments into consideration, it does not print the source code. Pier also provides a package ShoutPier for syntax highlighting of Smalltalk code, so I guess it would require little work to bring the two together. You can find the mentioned extension packages in http://source.lukas-renggli.ch/pieraddons.html.
Pharo browsers seem to use syntax highlighting.
What difficulty are you having reading Smalltalk code using the browsers and senders/implementors ?
Edit: Would something that produces UML give the overview you're looking for? The Dandelion website only shows downloads for old Squeak versions - I don't know if they would work with Pharo.
And perhaps this GSoC project "Generate UML diagrams from Smalltalk code for Pharo" suggests not.
Here's how I did it on my Mac, I think this should work on other platforms too.
Save your categories to a Monticello local folder on your disk -- see the Pharo manual on how to do this: http://book.pharo-project.org/book/PharoTools/Monticello/?_s=hdGOLc_FXsvVY1iR&_k=YYH-Ln8f5mtWZ8z2&_n&148
Browse to this folder, and unzip the .mcz file
You'll see all your code in snapshot/source.st file
You'll need to edit this a bit, to remove the ! characters for e.g., there might be a tool to do this?
-Eric.
There is webdoc project, which allows you navigating code in web browser:
http://ss3.gemstone.com/ss/webdoc.html
(and of course you can print code from your favorite web browser)..
1) Install shout from www.squeaksource.com
2) I don't know. May be you can customize shout.
3) In gnu-smalltalk you have a smalltalk mode for emacs. But I am not pretty sure to understand what you are looking for.

Printing code with syntax highlighting? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 months ago.
Improve this question
I have occasion to need to print code (Horrors!!! ;) ), and i was wondering what editor or tool would i use to print that code out with proper formatting and syntax highlighting? If it's important, it will be c# code but ideally the tool will work for as many languages as possible. Can Notepad++ or something handle this?
You can use Vim! It's probably installed already if you're on modern Linux/MacOS and an easy install if not.
:syntax will turn syntax highlighting on and :hardcopy will print it. There's syntax highlighting definitions for many languages out there. The default look is usually optimised for screen display, but you can fix that.
Simply open the file on command line with vim <filename>, type :syntax on<ENTER>, then :hardcopy<ENTER> to print it. Quit Vim with :q!<ENTER>.
There's also the :TOhtml command which will open the current selection as HTML in a new Vim window. Capture the entire document with :%y<ENTER> followed by :TOhtml<ENTER> to open it.
Yes, Notepad++ can certainly print code with syntax highlighting.
Colour printing would obviously be preferable, but on the occasions when I've printed in black and white, the subtle differences in colour [rendered as shades of grey, of course] can be difficult to distinguish.
However, I think a little customisation of the colour schemes should make this less of a problem.
New Answer:
Use TextMate. It prints colored code automatically. There's no setup. Just print. In case previous or newer versions can't do this I'm using TextMate version 2.0.23
Old Answer, and the answer for people who don't have Macs:
Use vim. Its the easiest method to do it in my experience by far, that is, once you know how.
Vim comes pre-installed on Macs, btw. And I know how you special people like colors, so I'm going to make this impatientbusinessman-proof for the benefit of all.
1.) open file
vim filename.m
2.) enable syntax coloration (mine did not have enabled by default)
:syntax on
3.) print
:hardcopy
Vim will choose your system's default printer without asking you so make sure you set that up first.
4.) exit the program (this is actually not a given)
:q
http://pygments.org/ is one option. It supports a ton of languages, and since it's written as a python library, you can script the conversion process however you want.
Visual Studio will, and allows you have a completely separate configuration for printing.
I recently compared the 2 solutions already mentioned : vim & pygments. They both give great results, but there is how you can practically use them quickly:
pygments does not provide direct export to PDF. Hence, the simplest solution I found was to export to HTML and then use wkhtmltopdf. You can combine both operations using the following bash script:
src2pdf () {
local noext="${1%.*}"
pygmentize -O full -o "$noext.html" "$1"
# enabling line wrapping in <pre> blocks
perl -i -wpe '/<style.*>$/&&($_.="pre{white-space:pre-wrap;}\n")' "$noext.html"
wkhtmltopdf "$noext.html" "$noext.pdf"
rm "$noext.html"
}
for vim, it's as simple as this: TERM=xterm-256color vim '+hardcopy >out.ps' +q code.src
I found out that the $TERM environment variable can affect the output colors, so I prefer to set it explicitly.
And finally, you may need to tweak your .vimrc a little:
set printfont=:h9
set printoptions=number:y,left:5pc
The tool called enscript is very much the tool for doing this. It is very powerful, is not tied to an editor nor a language and you can create PDF's with syntax highlighting.
The documentation pretty much says it all.
enscript man page
Under unix you might want to try a2ps. It is flexible and produces nice results.
I while ago I created a household python script that wraps pygments into a small console utility. It works with any language supported by pygments.
Also if you happen to use eclipse, you could simply copy the selected text in the editor and then paste it in a RTF-aware editor like MS Word - it will preserve all the colors, fonts and formatting.
If you have problems with Visual Studio 2012 concerning the highlighted printing an handeling the described problem:
Download and install this Power Tool which implements the color
printing, besides some other features and bug fixes. Works for me!
Solution For Bash Shell
Add this line to ~/.bashrc if you are using UBUNTU
or, to ~/.bash_profile if you are using MAC
If that file does not exists, create it.
alias lprc='vim -me -c ":syntax on" -c ":hardcopy" -c ":q"'
source ~/.bashrc or source ~/.bash_profile
To print colored hello.py just do this:
lprc hello.py instead of lpr hello.py
Use ConTEXT programming editor (which is free). I am using it for both generating .pdf-s with syntax highlighted source code and printing to paper.
There are many ConTEXT syntax highlihting definitions to download and you can make your own highligher file which will BTW be highlighted using the ConTEXT Highlighter Files highlighter definition.
I do it downloading js and css files from
https://prismjs.com/
There are so many 5-7 options to select the theme and language highlighter. Once you select a theme and download the tiny js/css files the next thing you need to do is rename the code file to html, and call the css/js files. Open the html in a browser and print it. Done!
You can also use this in case you've to print with bnw syntax highlighting https://github.com/SGI-CAPP-AT2/code-highlight-n-print

Resources