manuels / texlive.js

Compiling LaTeX (TeX live) in your browser
http://manuels.github.com/texlive.js/
GNU General Public License v2.0
1.25k stars 140 forks source link

How to run multiple times for longtable #50

Open Arlen22 opened 7 years ago

Arlen22 commented 7 years ago

I'm trying to figure out how I would run this multiple times, which is needed when using longtable.

Any thoughts?

manuels commented 7 years ago

What is the error that you are getting? What is the code that you are running?

Arlen22 commented 7 years ago
Package longtable Warning: Column widths have changed
(longtable)                in table 1 on input line 126.

Package longtable Warning: Table widths have changed. Rerun LaTeX.

[2] (./input.aux) )
(see the transcript file for additional information)<//texmf-dist/fonts/type1/p
ublic/amsfonts/cm/cmr10.pfb>
Output written on input.pdf (2 pages, 32845 bytes).
Transcript written on input.log.

I'm using the code at http://manuels.github.com/texlive.js/

However if I duplicate the line https://github.com/manuels/texlive.js/blob/master/pdftex.js#L171, it still only runs one time. I can't really tell why.

manuels commented 7 years ago

You cannot re-run emscripten scripts without configuring this at runtime. Probably the easiest is to create a new PDFTeX instance and copy the files created when running the first time into this emscripten environment.

ghost commented 7 years ago

You can move files, e.g., .aux and .toc, from one compilation to another like this though:

var myauxfile = pdftex_first.FS_readFile("/input.aux");

pdftex_second.FS_createDataFile("/", "input.aux", myauxfile["result"][0], true, true, true);

Works like magic.

Arlen22 commented 7 years ago

Ok, interesting. Ended up changing the return statement of compileRaw to this and made the related changes that you see here, such as moving onMessage out of the constructor and adding a few arguments to compileRaw. Written in typescript.

            return PromiseHelper.chain(commands)
                .then(sendCompile)
                .then(() => self.FS_readFile('/input.aux'))
                .then(file => {
                    console.log(file);

                    if (count < 3) {
                        worker = new Worker(opt_workerPath);
                        worker.onmessage = workerOnMessage.bind(self);
                        initialized = false;
                        return self.compileRaw(source_code, file, count + 1);
                    } else {
                        return self.FS_readFile('/input.pdf');
                    }

                    //return PromiseHelper.chain(commands);
                })