[OS X TeX] Two macros for TeXShop & iTeXMac
Will Robertson
will at mecheng.adelaide.edu.au
Wed Jul 14 02:33:41 CEST 2004
On 14 Jul 2004, at 9:38 AM, Alain Schremmer wrote:
> I did not see what makes the tabular a floating one but I take your
> word for it. Is there a way to make it non floating? A lot of my
> tables are two or three rows and really part of the body text.
>
> Any other such in preparation?
By floating I mean that the tabular is wrapped up in the table
environment with a caption and label so you can refer to it (and if
there isn't space for it, it will move to a page where it can fit).
If you just want a centered table in your text that doesn't move, I've
attached a new TeXShop macro to the end of this email that will do
this. I'll include it in the download next time I update the macros
(maybe soon, maybe not. You know where to find me if you have
problems!).
The question is: do you find them useful, or is it just as easy to do
it by hand?
Best of luck,
Will
<------CUT HERE------>
--Applescript
property indent_with_spaces : " " -- edit this if you want other than
2 spaces for your indent
property cell_text : "ð " -- edit this if you want a different text blob
tell application "TeXShop"
set q1 to display dialog "This macro creates a new floating tabular."
& return & "Enter the number of columns you'd like and then input the
type of tabular you want (booktabs is available in the memoir class)."
default answer "3" buttons {"Cancel", "Plain", "Booktabs"} default
button "Booktabs"
set NCOLS to the text returned of q1
set tabtype to the button returned of q1
set q2 to display dialog "Enter the number of rows you'd like (not
including a header row) and whether you'd like tabs or spaces for the
indents." default answer "3" buttons {"Cancel", "Spaces", "Tabs"}
default button "Tabs"
set NROWS to the text returned of q2
set indenttype to the button returned of q2
if NCOLS < 1 or NROWS < 1 then
display dialog "Eh? Zero or negative rows or columns? Silly rabbit."
buttons {"ÁOops!"} default button 1
return
end if
if the indenttype = "Tabs" then
set the indent to " "
else
set the indent to indent_with_spaces
end if
if the tabtype = "Booktabs" then
set the toprule to "\\toprule"
set the midrule to "\\midrule"
set the bottomrule to "\\bottomrule"
else
set the toprule to "\\hline"
set the midrule to "\\hline"
set the bottomrule to "\\hline"
end if
set the beforetext to "\\begin{center}" & return & indent & indent &
"\\begin{tabular}"
set the aftertext to indent & indent & bottomrule & return & indent &
"\\end{tabular}" & return & "\\end{center}"
set the column_preamble to "{@{} c"
set the one_row_text to indent & indent & cell_text
if NCOLS > 1 then
repeat with c from 2 to NCOLS
set the column_preamble to column_preamble & "c"
set the one_row_text to one_row_text & "& " & cell_text
end repeat
end if
set the column_preamble to column_preamble & " @{}}" & return
set the one_row_text to one_row_text & "\\\\ "
set the midtext to Â
indent & indent & toprule & return & Â
one_row_text & return & Â
indent & indent & midrule & return
-- This is the first header row surrounded by rules, not counted in
the number of rows
repeat with r from 1 to NROWS
set the midtext to midtext & one_row_text & return
end repeat
set alltext to beforetext & column_preamble & midtext & aftertext
set the content of the selection of the front document to alltext
end tell
-----------------------------------------------------
Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.
More information about the macostex-archives
mailing list