mkrphys / ipython-tikzmagic

IPython magics for generating figures with TikZ
BSD 3-Clause "New" or "Revised" License
160 stars 44 forks source link

When latex compilation fails, display error message in notebook instead of console #6

Closed DavidPowell closed 8 years ago

DavidPowell commented 8 years ago

I have found this extension very useful. However, with latex and tikz, it is very easy to make syntax errors which cause compilation to fail. When this happens, the latex error message does not display in the notebook, but instead displays in the console used to start the notebook. This makes diagnosing the errors even more difficult.

I assume that it should be possible to capture stdout/stderr from the latex process, and display it in the notebook output in case of an error, but I have not looked into this yet.

mkrphys commented 8 years ago

Dear David,

I agree that this should be possible and it should not be hard to implement. Unfortunately, I do not have time for this at the moment. But feel welcome to have a look at this issue. I will happily accept a pull request adding this feature.

Cheers, Michael

On 15.10.2015, at 01:17, David Powell notifications@github.com wrote:

I have found this extension very useful. However, with latex and tikz, it is very easy to make syntax errors which cause compilation to fail. When this happens, the latex error message does not display in the notebook, but instead displays in the console used to start the notebook. This makes diagnosing the errors even more difficult.

I assume that it should be possible to capture stdout/stderr from the latex process, and display it in the notebook output in case of an error, but I have not looked into this yet.

— Reply to this email directly or view it on GitHub https://github.com/mkrphys/ipython-tikzmagic/issues/6.

DavidPowell commented 8 years ago

I just had a look through the code. Latex errors are already captured by reading the log file, so there is no need to capture stderr. The problem is that if a latex error occurs, it is just added to the display data, but the magic processing continues. This inevitably results in an error further on due to missing files. Because an exception gets raised, the text display data never gets shown to the user.

The simple fix is if the latex error log is returned, just display it and return immediately. A pull request is on its way.

mkrphys commented 8 years ago

Sorry for the (very) late reply. I just merged the pull request. Thanks for looking into this!

Best, Michael

On 27.10.2015, at 05:02, David Powell notifications@github.com wrote:

I just had a look through the code. Latex errors are already captured by reading the log file, so there is no need to capture stderr. The problem is that if a latex error occurs, it is just added to the display data, but the magic processing continues. This inevitably results in an error further on due to missing files. Because an exception gets raised, the text display data never gets shown to the user.

The simple fix is if the latex error log is returned, just display it and return immediately. A pull request is on its way.

— Reply to this email directly or view it on GitHub.