LaTeX commands to type > (greater than) and < (less than) in KaTeX - youtrack

Youtrack and many other web apps use KaTeX to render mathematical notation and markdown for all other things.
However markdown parser treats certain characters in a special way and interferes with KaTeX.
For example the following equation
\begin{equation}
X_i = \begin{cases}
0, t_i < t_{i-1} \\
1, (t_i - t_{i-1}) > t_0 \\
X_{i-1}, otherwise
\end{cases}
\end{equation}
Would render incorrectly as
Note the missing line.
The reason is that < and > and the text between are treated as an HTML tag and thus ignored.
The intended rendering would instead look like
Reordering the cases resolves the issue as well as replacing < with \leq and > with \geq. But both solutions seem incomplete and in the latter case change the meaning of the equation.
In LaTeX there are no predefined commands for < and > and KaTeX currently does not support \newcommand yet.

I have posted a similar question on tex stackexchange. And while it was closed there as off-topic, users provided a solution in comments. Using \lt for < and \gt for > is supported in KaTeX. So the equation should be typed as
\begin{equation}
X_i = \begin{cases}
0, t_i \lt t_{i-1} \\
1, (t_i - t_{i-1}) \gt t_0 \\
X_{i-1}, otherwise
\end{cases}
\end{equation}

Related

What do the ASCII characters preceding a carriage return represent in a PDF page?

This is probably a rather basic question, but I'm having a bit of trouble figuring it out, and it might be useful for future visitors.
I want to get at the raw data inside a PDF file, and I've managed to decode a page using the Python library PyPDF2 with the following commands:
import PyPDF2
with open('My PDF.pdf', 'rb') as infile:
mypdf = PyPDF2.PdfFileReader(infile)
raw_data = mypdf.getPage(1).getContents().getData()
print(raw_data)
Looking at the raw data provided, I have began to suspect that ASCII characters preceding carriage returns are significant: every carriage return that I've seen is preceded with one. It seems like they might be some kind of token identifier. I've already figured out that /RelativeColorimetric is associated with the sequence ri\r. I'm currently looking through the PDF 1.7 standard Adobe provides, and I know an explanation is in there somewhere, but I haven't been able to find it yet in that 756 page behemoth of a document
The defining thing here is not that \r – it is just inserted instead of a regular space for readability – but the fact that ri is an operator.
A PDF content stream uses a stack based Polish notation syntax: value1 value2 ... valuen operator
The full syntax of your ri, for example, is explained in Table 57 on p.127:
intent ri (PDF 1.1) Set the colour rendering intent in the graphics state (see 8.6.5.8, "Rendering Intents").
and the idea is that this indeed appears in this order inside a content stream. (... I tried to find an appropriate example of your ri in use but cannot find one; not even any in the ISO PDF itself that you referred to.)
A random stream snippet from elsewhere:
q
/CS0 cs
1 1 1 scn
1.5 i
/GS1 gs
0 -85.0500031 -14.7640076 0 287.0200043 344.026001 cm
BX
/Sh0 sh
EX
Q
(the indentation comes courtesy of my own PDF reader) shows operands (/CS0, 1 1 1, 1.5 etc.), with the operators (cs, scn, i etc.) at the end of each line for clarity.
This is explained in 7.8.2 Content Streams:
...
A content stream, after decoding with any specified filters, shall be interpreted according to the PDF syntax rules described in 7.2, "Lexical Conventions." It consists of PDF objects denoting operands and operators. The operands needed by an operator shall precede it in the stream. See EXAMPLE 4 in 7.4, "Filters," for an example of a content stream.
(my emphasis)
7.2.2 Character Set specifies that inside a content stream, whitespace characters such as tab, newline, and carriage return, are just that: separators, and may occur anywhere and in any number (>= 1) between operands and operators. It mentions
NOTE The examples in this standard use a convention that arranges tokens into lines. However, the examples’ use of white space for indentation is purely for clarity of exposition and need not be included in practical use.
– to which I can add that most PDF creating software indeed attempts to delimit 'lines' consisting of an operands-operator sequence with returns.

Latex escaping in MatPlotlib

There are a number of situations where it is useful to set matplotlib.rcParams['text.usetex'] = True. In this case, special LaTeX characters such as % have to be escaped in places like axis labels. Is there a function built in to matplotlib for escaping LaTeX symbols?
There is a hint of such a thing in the docs here and here, but no clear mention.
The specific problem I am trying to tackle is using a matplotlib.ticker.PercentFormatter, where a custom symbol (symbol=r'\%') must be used if rcParams['text.usetex'] is true. I am trying to add a PR that will escape the percent symbol in PercentFormatter if rcParams['text.usetex'] is enabled, but it does not make sense to only check for the percent symbol in that case, so I would like to escape the entire symbol string.

idl strange symbols in file

I've written several IDL programs to analyse some data. To keep it simple the programs read in some time varying data and calculate the fourier spectrum. This spectrum is written to file using this code:
openw,3,filename
printf,3,[transpose(freq),transpose(power)],format='(e,e)'
close,3
The file is then read by another program using this code:
rdfloat,filename,freq,power,/double
The rdfloat procedure can be found here: http://idlastro.gsfc.nasa.gov/
The error i get when trying to read the a file is: "Input conversion error. Unit: 101"
When i delve in to the file being read, i notice several types of unrecognised characters. I dont know if these are a result of the writing to the file or some thing else related to the number of files being created (over 300 files)
These symbols/characters are in the place of a single number:
< dle> < dc1> < dc2> < dc3> < dc4> < can> < nak> < em> < soh> < syn>
Example of what appears in the file being read, Note they are not consecutive lines.
7.7346< dle>18165493007e+01 8.4796811549010105e+00
7.7354408697119453e+01 1.04459538071< dc2>1749e+01
7.7360701595839< can>28e+01 3.0447318983094189e+00
Whenever I run the procedures that write the files, there is always at least one file that has some or all of these characters. The file/s that contains these characters is always different.
Can anyone explain what these symbols are and what I might be doing to create them as well as how to ensure they are not written to file?
I see two things that may be causing a problem. But first, I want to suggest a few tips.
When you open a file, it is useful to use the /GET_LUN keyword because it allows IDL to find and use a logical unit number (LUN) that is available (e.g., in case you left LUN 3 open somewhere else). When you print formatted data, you should specify the total width and number of decimal places. It will make things easier because then you need not worry about changing spacings between numbers in a file.
So I would change your first set of code to the following (or some variant of the following):
OPENW,gunit,filename[0],/GET_LUN,ERROR=err
FOR j=0L, N_ELEMENTS(freq) - 1L DO BEGIN
PRINTF,gunit,freq[j],power[j],FORMAT='(2e20.12)'
ENDFOR
FREE_LUN,gunit ;; this is better than using the CLOSE routine
So the first potential issue I see is that if your variable power was calculated using something like FFT.pro, then it will be a complex float or complex double, depending on the input and keywords used.
The second potential issue may be due to an incorrect format statement. You did not tell PRINTF how many columns or rows to expect. It might not know how to handle the input properly, so it guesses and may result in those characters you show. Those characters may be spacing characters due to the vague format statement or the software you are using to look at the files (e.g., I would not recommend using Word to open text files, use a text editor).
Side Note: You can open and read the file you just wrote in a similar fashion to what I showed above, but changed to the following:
n = FILE_LINES(filename[0])
freq = DBLARR(n)
power = DBLARR(n)
OPENR,gunit,filename[0],/GET_LUN,ERROR=err
FOR j=0L, N_ELEMENTS(freq) - 1L DO BEGIN
READF,gunit,freq[j],power[j],FORMAT='(2e20.12)'
ENDFOR
FREE_LUN,gunit ;; this is better than using the CLOSE routine

.Net XmlTextWriter: prevent replacing of > or < with > or <

I'm creating xml-like mark-up language using System.Xml.XmTextWriter that will be read by a third party app.
In this mark-up language, symbols > and < when inside an element, need to show up as, but the XmlTextWriter converts them to &gt ; and &lt ; (no spaces, I just added those because of formatting on here).
Any ideas on how to prevent this while still working with XmlTextWriter?
You can output raw XML (no escaping) with the XmlTextWriter.WriteRaw method.
http://msdn.microsoft.com/en-us/library/z7sb8fsy.aspx

.net Masked Text Box

What is the mask for "percentage", in a WinForms application (VB.net)?
Per the documentation here: http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx
\ Escape. Escapes a mask character,
turning it into a literal. "\\" is the
escape sequence for a backslash.
So the mask for a % sign is \%
Before posting, I made up a quick and dirty winforms app, tried it and it works.
Edit - added although this next item in the documentation makes it look like just a straight % sign should work without the backslash, so I tried it and it works as well.
All other characters Literals. All
non-mask elements will appear as
themselves within MaskedTextBox.
Literals always occupy a static
position in the mask at run time, and
cannot be moved or deleted by the
user.
textEdit1.Properties.Mask.MaskType = Numeric;
textEdit1.Properties.Mask.EditMask = "00.00%%";
textEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;
http://community.devexpress.com/forums/t/59535.aspx