Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 3 
Send Topic Print
Exporting to Latex (Read 42684 times)
Roy
Full Member
*
Offline



Posts: 4

Exporting to Latex
Dec 14th, 2009, 7:43am
 
I am trying to figure out a simple work flow that puts all my notes in TBX and ends up with Latex documents. My work has a lot of mathematics in it.

It would seem that the following design should work:
- While taking notes, organize them by source.
- There are multiple sources for each concept, so make aliases of the notes and create another hierarchy around the concepts.
- To create a latex document, create a set of prototype containers (article,abstract, section,subsection,itemized-list,enumerated-list,description-list,item); then structure another set of aliases into theses containers, and export into a latex document.

Does this approach make sense?

Has someone already done the export to latex step?

Back to top
 
 
  IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Exporting to Latex
Reply #1 - Dec 21st, 2009, 4:53pm
 
Hi Roy-

Although I can't gauge your technical interest (math? LaTeX?), but you might want to have a look at Fletcher Penny's work with MultiMarkdown: http://fletcherpenney.net/multimarkdown/ You won't be able to directly utilize his scripts in Tbx, but his approach is well worth understanding for what you want to do. Take a look at the OmniOutliner and Scrivener interfaces in particular. Now that Tbx 5.0 is released, I'm interesting in getting this type of functionality working here.

My first take on your workflow is that you're creating a Tbx "version" of your LaTeX document when you should be able to work at a higher level structure. The export to LaTeX should be smart enough to relate your Tbx structure to a chosen LaTeX format. In other words, the export should be thought of as a translation, and not merely a format conversion. (Or that you must create the LaTeX file format in Tbx and then do a text export)

But maybe I don't completely get your post. (And perhaps I'm overlooking something about Tbx export.)

HTH, Charles
Back to top
 
 
WWW   IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Exporting to Latex
Reply #2 - Dec 22nd, 2009, 2:47pm
 
I am a big fan of the MultiMarkdown format, and have in the past tried to coerce Tinderbox into producing MMD files. It is about 99% possible. There are a few areas where things cannot be easily mapped over, list types is the most troublesome. One nice thing about MMD is that it can handle raw HTML as a back-up, so some of the things TBX does not allow you full control over (such as images) can be ignored. However, it is isn't easy. It might be easier just to go straight to XHTML and then to LaTeX from that.

You could use MMD to an extent, by bypassing the main parsing function (and thus not having to learn a shred of MMD syntax) and simply utilising the XSLT which converts XHTML to LaTeX. Specifically, you are looking for this sequence:

Code:
~/Library/Application\ Support/MultiMarkdown/bin/SmartyPants.pl | xsltproc -nonet -novalid ~/Library/Application\ Support/MultiMarkdown/XSLT/memoir.xslt - | ~/Library/Application\ Support/MultiMarkdown/Utilities/cleancites.pl 



Which assumes English as the primary language and a default MMD installation in your user Library folder under Application Support.

Now, to use this with Tinderbox, you’ll need to create an XHTML template for the parent container you wish to export as a LaTeX file. Looking something like:

Code:
Document
    Part I
        Chapter 1
        Chapter 2
    Part II
        Chapter 3
    ... 



Because MultiMarkdown uses XSLT to do the conversion, it needs a valid XML file to work with, not a run-of-the-mill HTML document. At its most basic, this could look something like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>^title^</title>

</head>

<body>

^children(SectionTemplate)

</body>
</html> 



You’ll need to change the default for HTMLImageEnd to `/>` as well; make sure the document is in “prose” mode to avoid BRs since you cannot fix those to `<br/>`; and always export using the HTML preview window on a master container for the document, rather than using the File menu.

You might also want to create a default template for each section of text, so that you can get proper header depth (the built-ins do not provide this). You could use something like:

Code:
<h^value($OutlineDepth - 1)^>^title^</h^value($OutlineDepth - 1)^>

^text

^children(SectionTemplate) 



This will compute the header depth at minus one of what OutlineDepth really is, which I’m doing because everything is going into a document container for easy single-file export. You could simply get the value of OutlineDepth directly otherwise.

For me, doing all of the above generated a valid LaTeX document in one shot.

Now, to include your own LaTeX commands (which you will need for math support), the best way to do this is enclose them in an HTML comment* right in Tinderbox. This will cause them to be passed through the MMD engine. An example could be:

Code:
This is a footnote<!-- \footnote{And its contents} --> example. 



While this might seem like a lot of messing around, I think it would be dramatically easier than trying to create a LaTeX template in TBX because it is geared toward XML/HTML style exporting. While most of its commands can be altered suitably, there are a few which cannot be easily done. Links and images, while the surrounding matter can be changed, still generate XML/HTML stuff in the middle. You would still get an `href="LINK"` output in the middle, in other words. Additionally, header depth would probably be much more difficult to do in Tinderbox since I can hijack OutlineDepth for H# values, in LaTeX you would need to map a numeral to different syntax calls somehow. Not sure how that would be best done.

From this point on, you could use Tinderbox normally. In other words, use its formatting tools as WYSIWYG; use links; and so forth. No need to type syntax directly into Tb (with the exception of math).

Incidentally, in that command line above I linked to the memoir.xslt, which produces a memoir class LaTeX file. There are plenty of other options however. Download MultiMarkdown and peruse the XSLT folder for available choices. If you have a passing knowledge of XSLT (or can glean how to do it from some of the simpler examples) it is pretty easy to make your own class templates, too.




  • You might need to tweak something in order to do this. I forget if this can be done with the default installation.


Back to top
 
« Last Edit: Dec 22nd, 2009, 4:03pm by Ioa Petra-ka »  

Av
  IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Exporting to Latex
Reply #3 - Dec 22nd, 2009, 3:06pm
 
Here is a simple demonstration Tinderbox file with all of the above discussion applied to it. It isn't intended to be used verbatim, but might prove to be a starting point for anyone wishing to work this way.

Link: http://www.semigreenpenny.com/img/forums/mmd_latext_example.tbx.zip
Back to top
 
 

Av
  IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Exporting to Latex
Reply #4 - Dec 22nd, 2009, 3:26pm
 
Wow! Very nice, Amber. Thanks for sharing...

:) Charles
Back to top
 
 
WWW   IP Logged
john plum
Full Member
*
Offline



Posts: 5

Re: Exporting to Latex
Reply #5 - Feb 10th, 2010, 8:35pm
 
@Amber: I read your advice with interest, and was about to take off and try it when I noticed you kindly supplied example files. The task here to tackle is important to me, and greatly extends the usefulness of tinderbox.
Documents need to be printable in a professional format. Otherwise I have been choosing to write with plain text files in textmate and using its project folder. That is sufficient but I lose the outliner capabilities of tinderbox, its ease in numerous matters, and screen presentation for writing.  This extends TBX capabilities, and means I can write in one programme.
Also, your reply has extended my understanding of tbx and headings, confirming what I suspected. Most considerate: thank you.  Smiley

OK...15 minutes later, I have a nicely rendered document, through  XML to latex (I already had multimarkdown in place).

A question: I expected to have to apply the script, but that was done on export, to produce a tex file. Where/how in tbx is this script performed? I can't see. Shocked
Back to top
 
« Last Edit: Feb 10th, 2010, 9:45pm by john plum »  
  IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Exporting to Latex
Reply #6 - Feb 10th, 2010, 10:11pm
 
Yes, I embedded the shell command right into the example file, and with a default MMD installation the experience should be, as with you, literally a matter of minutes to print-time.

If you want to see or tweak the command, get info on the top level container, and check out HTMLExportCommand. If you fiddle with that a lot, it might be a good idea to throw it into KeyAttributes, or set things up so that you can type the XSLT name into an attribute somewhere.

This attribute is fantastic. It basically just takes whatever data Tinderbox exports, runs shell commands on it, and then saves the result of those shell commands. I'm just running the core MMD post-processing scripts in that command, producing a LaTeX file straight out of Tb.

And some people say Tinderbox doesn't have a lot of export options. Wink
Back to top
 
« Last Edit: Feb 10th, 2010, 10:14pm by Ioa Petra-ka »  

Av
  IP Logged
john plum
Full Member
*
Offline



Posts: 5

Re: Exporting to Latex
Reply #7 - Feb 10th, 2010, 10:34pm
 
"And some people say Tinderbox doesn't have a lot of export options"
Well, you've cracked it Amber.
Thanks for the extra info. I had a quick hunt before my last post but missed the HTML export command attribute..i'm new to v.5.0.
This is great: TBX for working and publishing in all respects.  
Thank you very much.
By the way I had only recently tried the MMD CMS, and so now this has followed ...
Textmate is fine; i found text2tags very useful as a bundle with it. So is Blosxom (I run a blog, and shall continue with that script) but for documents and journals I wished to work from TBX, for their evolution. ..( oh also GTD, where necessary) This is the best, now.Delighted, truly. Peace of mind.

By the way i have a brilliant shopping cart with TBX, after considering all sorts.. complete with all kinds of niceties,  all down to templating, and user attributes.
Back to top
 
 
  IP Logged
john plum
Full Member
*
Offline



Posts: 5

Re: Exporting to Latex
Reply #8 - Feb 10th, 2010, 10:43pm
 
Oh I see my earlier version of tbx has the HTMLExportCommand. I had never used it, all the reading I had done implied Applescript and, Agent actions with shell commands. You're right Amber it is truly fantastic. Just the ticket.  Cheesy
Back to top
 
 
  IP Logged
Stéphane R
Full Member
*
Offline



Posts: 71

Re: Exporting to Latex
Reply #9 - Feb 11th, 2010, 9:38am
 
That's really amazing! Thanks a million


Do you have any idea on how to use the \section*{} option, i.e. removing the section number of a LaTeX heading, in this set-up?
Back to top
 
 
  IP Logged
john plum
Full Member
*
Offline



Posts: 5

Re: Exporting to Latex
Reply #10 - Feb 11th, 2010, 10:27am
 
That would have to be your xslt template. I haven't yet explored these - I must do so soon - I imagine it's straightforward. But this latex information should help for a start:

Quote:
LaTeX enumerates by default all sections. It is possible to disable numbering of a specific section by adding an asterisk (*) after the section command like this:

\section*{Introduction}
\subsection*{Test}
However, when you do this, the section is not added to the table of contents. Sometimes you want to disable section numbering but still need to generate a table of contents, or you want to have bookmarks in the generated PDF file. Add this code at the start of your document, and your problem is solved:

% disables chapter, section and subsection numbering
\setcounter{secnumdepth}{-1}



One of the  xslt templates supplied in the MMD package may already do this.
Back to top
 
 
  IP Logged
john plum
Full Member
*
Offline



Posts: 5

Re: Exporting to Latex - No Enumeration
Reply #11 - Feb 11th, 2010, 10:58am
 
I had a brief look, but no time to test and refine, however this should serve as a pointer, and perhaps Amber can define it better.
In thr MultiMarkdown/XSLT directory, to the xhtml2Latex.xslt something like the definitions above could be added:

Code:
<xsl:text>}
\setcounter{secnumdepth}{-1}
{</xsl:text>  



I noticed some interesting examples there to look at, particularly, in this case, the poetry and article examples.
Back to top
 
 
  IP Logged
Stéphane R
Full Member
*
Offline



Posts: 71

Re: Exporting to Latex
Reply #12 - Feb 11th, 2010, 5:00pm
 
Unless I misunderstood - though -, one can only set section numbering on or off completely, but not specify the setting for specific headings only.
Still a great find (which I'll use), thanks a lot John!
Back to top
 
« Last Edit: Feb 11th, 2010, 5:01pm by Stéphane R »  
  IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Exporting to Latex
Reply #13 - Feb 11th, 2010, 6:01pm
 
Yes, the provided setting is global and will adjust the threshold depending on where it is set. If you want to just make some section titles un-numbered, that would be something you'd probably have to do post-export. MultiMarkdown is very structural, and doesn't have a lot of built-in control for typesetting concerns and local exceptions. It's great for producing standard documents rapidly, but for highly customised projects it is only good as a starting point.

For example, tweaking the XSLT to output un-number section LaTeX syntax will impact all of them. You could write custom XSLTs which looked for certain XHTML IDs and applied different rules, though that would require the ID (which is derived from the visible name) to be static.

One possibility would be to create a Tb attribute called "headerStyle" which lets you input an XHTML class into the template, producing a final result like this:

Code:
<h3 class="noNumber">Title of Section</h3> 



The XSLT could then look for h3.noNumber matches, and use the alternate LaTeX syntax accordingly.

The nice thing about custom XSLTs is that you can include more complete XSLTs and only define the exceptions in the derivative. So you could create a simple XSLT that has this one rule, and then have it reference the full memoir.xslt for the rest of the processing.
Back to top
 
« Last Edit: Feb 11th, 2010, 6:03pm by Ioa Petra-ka »  

Av
  IP Logged
Stéphane R
Full Member
*
Offline



Posts: 71

Re: Exporting to Latex
Reply #14 - Feb 11th, 2010, 6:05pm
 
Thanks, very helpful
Back to top
 
 
  IP Logged
Pages: 1 2 3 
Send Topic Print