13.11.2015 Views

my Latex and Tex4ht cheat sheet

my Latex cheat sheet - 12000.org

my Latex cheat sheet - 12000.org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

%TCIMACRO{\QSubDoc{Include empty}{\input{empty.tex}}}%<br />

%BeginExpansion<br />

\input{empty.tex}%<br />

%EndExpansion<br />

Now, close everything. Now main.tex is a master document. Now you can write \input{file.txt} in<br />

master.tex <strong>and</strong> SW will now inlcude the file.txt (assuming of course the file is in the same folder as master.tex).<br />

So, for each latex file that is meant to include input files, we must have an empty.tex file there, <strong>and</strong> add it at<br />

the bottom of the document itself as shown above.<br />

5.3 Adding <strong>Latex</strong> code into SW so that SW do not touch it<br />

sometimes I have a need to insert <strong>Latex</strong> code into the .tex file while using SW, but do not want SW to look at<br />

this code. This is code used by htlatex for example. One way to do that is by using encapsulated tex field. This<br />

field can be added either from the SW GUI, or directly in source code. To add it in source, let assume we want<br />

to add \ifdefined\HCode\href{../../index.htm}{up} in the <strong>Latex</strong> source file. Then write<br />

%<br />

%TCIMACRO{\TeXButton{TeX field}<br />

%{ \ifdefined\HCode\href{../../index.htm}{up} }<br />

%}<br />

%BeginExpansion<br />

\ifdefined\HCode\href{../../index.htm}{up}<br />

%EndExpansion<br />

Notice what we did. The code has to be put in 2 places. In the comment <strong>and</strong> inside the BeginExpansion<br />

<strong>and</strong> %EndExpansion block.<br />

That is the only reliable way to insert <strong>Latex</strong> code for use by tex or tex4ht without having SW see it.<br />

Otherwise, SW can change it or move it around, or worst, comment it out. Now, the above can be processed OK<br />

by htlatex, since the TexField is a comment, but the code is still there in the second block.<br />

92

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!