LaTeX forum ⇒ Decision Guidanceauto align tidy codes

Don't know which editor is the right one for you? Then this is the place to go!
casperyc
Posts: 46
Joined: Thu Oct 15, 2009 11:23 pm

auto align tidy codes

Postby casperyc » Wed Jan 06, 2010 5:51 pm

suppose i input

  1. Year&Premium&Expenses&Acc.of $P_t-e_t$&Death Cost& \multicolumn{1}{c}{Survival Cost} & \multicolumn{1}{c}{In force expected net $CF$}\\[1.2ex]
  2. $t$&$P_t$&$e_t$&$(P_t-e_t)(10.8)$&$10,000q_{62+t-1}$& \multicolumn{1}{c}{$p_{62+t-1}S_t$} & \multicolumn{1}{c}{$(CF)_t$}\\[1.2ex]
  3. 1&3,091,79&92.75&3238.96&101.12&0.00&3137.84\\
  4. 2&3,091,79&92.75&3238.96&113.44&0.00&3125.52\\
  5. 3&3,091,79&92.75&3238.96&127.16&9872.84&-6761.04


is there any editor would auto matically "tidy" it a bit to
  1. {Year} & {Premium} & {Acc.~of $P_t-e_t$} & {Death Cost} & {Survival Cost} & {In force expected net $CF$} \\
  2. {$t$} & {$P_t$} & {$(P_t-e_t)(10.8)$} & {$10000q_{62+t-1}$} & {$p_{62+t-1}S_t$} & {$(CF)_t$} \\
  3. \midrule
  4. 1 & 309179 & 3238.96 & 101.12 & 0.00 & 3137.84 \\
  5. 2 & 309179 & 3238.96 & 113.44 & 0.00 & 3125.52 \\
  6. 3 & 309179 & 3238.96 & 127.16 & 9872.84 & -6761.04 \\


i.e. aligne the ‘&' symbol
every time if i have to do manually
it's a pain

Thanks

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Postby phi » Thu Jan 07, 2010 11:07 pm

With Emacs and AucTeX, you can type
  1. M-x align RET

to get
  1. Year & Premium & Expenses & Acc.of $P_t-e_t$ & Death Cost & \multicolumn{1}{c}{Survival Cost} & \multicolumn{1}{c}{In force expected net $CF$} \\[1.2ex]
  2. $t$ & $P_t$ & $e_t$ & $(P_t-e_t)(10.8)$ & $10,000q_{62+t-1}$ & \multicolumn{1}{c}{$p_{62+t-1}S_t$} & \multicolumn{1}{c}{$(CF)_t$} \\[1.2ex]
  3. 1 & 3,091,79 & 92.75 & 3238.96 & 101.12 & 0.00 & 3137.84 \\
  4. 2 & 3,091,79 & 92.75 & 3238.96 & 113.44 & 0.00 & 3125.52 \\
  5. 3 & 3,091,79 & 92.75 & 3238.96 & 127.16 & 9872.84 & -6761.04

casperyc
Posts: 46
Joined: Thu Oct 15, 2009 11:23 pm

Postby casperyc » Fri Jan 08, 2010 12:50 am

Hi there,

I am a windows user. I have just installed those two applications.
and I have no idea how to 'run'
  1. M-x align RET

could you explain a bit about that if you are a windows user as well?

Thanks.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Postby php1ic » Mon Jan 11, 2010 12:16 pm

I use emacs on linux so am assuming it is the same/similar to windows.

To do what phi suggested, highlight the contents of the table then press ALT+x (M-x means press x while holding the meta key, which is often ALT).

You will notice that the cursor has moved to the small bar at the bottom of the emacs window (the minibuffer) where M-x has also been written. If you now type "align" then press enter, the table will become aligned as required.

emacs has quite a steep learning curve to get the basics, but once you know them it is a very powerful tool. It even has a way of inserting tables into latex (almost) graphically. Google has all you will need, but this link shows you the basics of how to create a basic table.

http://xahlee.org/emacs/emacs_table.html


Return to “Decision Guidance”

Who is online

Users browsing this forum: No registered users and 2 guests