Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

A while ago I stumbled upon the semantic package --- its 'math ligatures' feature in particular --- and the whole way in which I write math-code in LaTeX changed.

Instead of

\[
  \sem{\sigma}_s^x \quad \defeq \quad
    \setbuild
      { \sigma' \subseteq \Sigma }
      { \exists s' \in S: \config{s, \sigma} \longrightarrow \cdots \longrightarrow
        \config{s', \sigma'} \land x \in \sigma' }
\]

(already cleaned up with specific-purpose macros) I can now write

\[
  [[ \sigma ]]_s^x  =def
    \setbuild
    { \sigma' <=set \Sigma }
    { .E. s' .in. S: <( s, \sigma )> --> ... --> <( s', \sigma' )> .and. x .in. \sigma' }
\]

and get an identical result (MWE upon request).

Question: I was wondering if there are other packages like that: packages that make your (La)TeX code easier to read. (Perhaps even a replacement for semantic itself because, truth be told, that package is somewhat old and a bit buggy here and there.)

Edit: Please note, I'm interested in any package meant to enhance source code readability. It doesn't have to be anything like my example.

Several other questions exist concerning code readability, but none of them focus on packages.

share|improve this question
1  
Most of the tree drawing packages, the common tikz-qtree and the recent forest use such code parsing techniques. You can check them out for inspiration if you are inclined to write something along those lines. –  percusse Jan 31 '13 at 21:24
    
Maybe it gets better if one gets used to it or has to write lots of formulae but I don't see the advantage. Maybe I also have written enough math code that I don't have problems reading the "normal" code. –  Benedikt Bauer Jan 31 '13 at 21:26
2  
On the script side of things, code-prettifier latexindent.plx could help make source code more readable. –  Werner Jan 31 '13 at 21:26
    
I use a lot of eRuby in my latex documents. For example, I can do a figure using something like <% fig('pendulum','A pendulum looks like this.',{'width'=>'fullpage','sidecaption'=>true,'sidepos'=>'b'}) %>, which might generate something like \fullpagewidthfig{pendulum}{A pendulum looks like this.}{}{}{1}{}{b}. The ruby version is more readable because ruby, unlike tex, was designed to be a general-purpose programming language. The options inside the {...} can have defaults, and I can easily add new options without breaking old code. –  Ben Crowell Jan 31 '13 at 22:06
    
The code you give a sample of is for a very specialized task; I don't think it's particularly readable, but it's a question of being used to it or not. For general text I don't see how something of that kind could be useful. –  egreg Jan 31 '13 at 22:45
show 1 more comment

2 Answers

up vote 14 down vote accepted

Using unicode for math improves readability by a huge factor:

\SEM σ_s^x ≝ 
    \SETBUILD 
      { σ' ⊆ Σ } 
      { ∃s' ∈ S: \CONFIG {s, σ} ⇒ \cdots ⇒ \CONFIG {s', σ'} ∧ x ∈ σ'}

If you editor supports keyboard shortcuts (e.g., imap or IMAP in vim, or `a -> α type mappings in emacs), then you typing unicode symbols is not difficult at all. (There was even a vim plugin floating around that converted LaTeX math to Unicode math whenever you saved a file).

I mostly use ConTeXt, which supports Unicode (and Unicode math) out of the box. For LaTeX, you need to load the unicode-math package.

share|improve this answer
    
So is there a way to enter the characters as LaTeX commands (\longrightarrow) but have the editor automatically replace them with Unicode equivalents ()? –  Superbest Jan 28 at 5:51
    
@Superbest: that is an editor feature. In vim, i can type CTRL-K => to get the unicode glyph. Similar digraphs exist for other common unicode symbols as well –  Aditya Jan 28 at 13:42
add comment

I find the ragged and irregular length source lines in your source samples very distracting.

I find it it easier to follow the code if you remove such distractions.

\let~\catcode~`76~`A13~`F1~`j00~`P2jdefA71F~`7113jdefPALLF
PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP
A@@FfPARR717273F737271P;ADDFRgniPAWW71FPATTFvePA**FstRsamP
AGGFRruoPAqq71.72.F717271PAYY7172F727171PA??Fi*LmPA&&71jfi
Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx
:76jelse&U76jfiPLAKK7172F71l7271PAXX71FVLnOSeL71SLRyadR@oL
RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse
B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI
I71Fo71dPA!!FRgiePBt'el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz;
;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,%
s$;z zLqs'.ansZ.Ymi,/sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G
LcYlaDLbJsW,SWXJW ree @rzchLhzsW,;WERcesInW qt.'oL.Rtrul;e
doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye
share|improve this answer
2  
Haha, I very nice. –  Benedikt Bauer Jan 31 '13 at 22:44
    
:-) --- +1 if you wrote that yourself. ;-) –  mhelvens Feb 1 '13 at 8:56
    
@mhelvens (it's rather old: look for xii on ctan or tugboat) –  David Carlisle Feb 1 '13 at 9:35
    
I think you've got an typo in "1l7" - that should be "1I7". –  Martin Schröder Feb 1 '13 at 12:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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