[OS X TeX] OmniOutliner & LaTeX

Alexandre Enkerli aenkerli at indiana.edu
Sun Jan 23 18:05:05 CET 2005


Le dimanche, 23 jan 2005, à 09:26 America/Indianapolis, Rene Borgella a 
écrit :
> I had used the OOexport with OO2, but can't get it to work with OO3.  
> I reinstalled from here 
> <http://www.opendarwin.org/~landonf/software/Omni-LaTeX/>. Is there 
> some other way to do this, please?
Well, I use the same scripts that I used with OO2 and I had modified 
them for my purposes. I'm not a scripter so those mods were minimal. In 
fact, I'm not completely sure which set of scripts was the basis for 
them. And I just tried, Landon Fuller's "LaTeX Export" script does 
generate an error.
I'm sure this will be remedied shortly and OO's own export plugin 
should have more features.
Another solution I used (didn't try it with OO3) is to XSLT the OPML 
export from OO. It did work rather well for my purposes. What I would 
do would be to have a column specifying whether the item was a section, 
an itemize, a description, or an enumerate. That was useful but still 
required tweaking the LaTeX output for several reasons...

Here's the script I use. It's pretty basic. It generates sections and 
descriptions, which I tend to use a lot in my lesson plans.
As I said, I don't remember who I stole the original from. Sorry! :-(

Alex



global topicList, numItems, myText
set return to ASCII character 13

--This section extracts the information from OmniOutliner
--The final object is topicList with one item per row and
--three items within each row.
tell front document of application "OmniOutliner"
	set numItems to the count of rows
	set the topicList to {}
	repeat with rowNumber from 1 to numItems
		set aRow to row rowNumber
		set myTopic to text of cell 2 of aRow
		set myLvl to the level of aRow
		set myNote to the note of aRow
		set the topicList to the topicList & {{myTopic, myLvl, myNote}}
	end repeat
end tell


set myText to ""
set lastLevel to 0
repeat with itemNum from 1 to numItems
	set myItem to item itemNum of the topicList
	set thisLevel to (item 2 of myItem)
	
	--calculate the appropriate indent (purely cosmetic)	
	set indentLine to ""
	repeat with indent from 2 to thisLevel
		set indentLine to indentLine & "	"
	end repeat
	
	--if indent of last line was greater than this line I know
	--that I have to add one or more <\end{description}>	
	if thisLevel < lastLevel then
		repeat with unindents from 1 to lastLevel - thisLevel
			set myText to myText & "	"
			set myText to myText & indentLine & "\\end{description}" & return
		end repeat
	end if
	
	--if the line is of level one it is to be treated as a new slide
	--if this is NOT the first line we also have to end the previous slide	
	if thisLevel = 1 then
		if itemNum > 1 then
			set myText to myText & return & return
		end if
		set myText to myText & "\\section{" & item 1 of the myItem & "}" & 
return
		if item 3 of myItem is not "" then
			set myText to myText & item 3 of the myItem & return
		end if
	end if
	
	--any level greater than one implies that it is an item in an itemized 
list
	--if the level has increased from the previous line we need to add
	--a <\begin{description}> before adding the item
	--the script does NOT support "skipping" levels when increasing indents
	--(it does support multi-level decrease)
	if thisLevel > 1 then
		if thisLevel > lastLevel then
			set myText to myText & indentLine & "\\begin{description}" & return
		end if
		set myText to myText & indentLine & "\\item " & item 1 of the myItem
	end if
	
	set myText to myText & return
	set lastLevel to thisLevel
	
end repeat

--after the last item, and any open {description}
if 1 < lastLevel then
	repeat with unindents from 1 to lastLevel - 1
		set myText to myText & "	\\end{description}" & return
	end repeat
end if

set the clipboard to myText
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list