bugGNU Octave - Bugs: bug #51782, publish creates incorrect latex

 
 

bug #51782: publish creates incorrect latex

Submitter:  andre <wienerschnitzel>
Submitted:  Fri 18 Aug 2017 07:05:25 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  siko1056
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 12 Sep 2017 09:33:00 AM UTC, comment #14: 

Thank you Rik an Dmitri for helping me closing this report.  We have had an examination period and I was quite busy, sorry for the delay.

Regarding comment #9, there must be a section start "##" before "<latex>", otherwise it will be treated as a usual Octave Code comment and explains the output of Dmitri in file #41710.  It should be:


%% Headline title
%
% Some *bold*, _italic_, or |monospaced| Text with
% a <http://www.octave.org link to GNU Octave>.
%%

# "Real" Octave commands to be evaluated
sombrero ()

## Octave comment style supported as well
#
# * Bulleted list item 1
# * Bulleted list item 2
#
# # Numbered list item 1
# # Numbered list item 2

##
# <latex>
# Some output only visible in LaTeX or PDF reports.
# \begin{equation}
# e^x = \lim\limits_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)^{n}
# \end{equation}
# </latex>


Another thing is, the default output directory in Matlab is, regardless of the output format, "html".  So this is as expected @Rik.

Regarding your pdflatex Error, I don't know your setup, but the generated LaTeX output of publish uses straight forward Matlab compatible standard LaTeX.  Maybe comment #10 helps you with this?

Anyways, thanks for testing and closing this item.  At least from my side everything works fine.

Kai Torben Ohlhus <siko1056>
Group Member
Wed 06 Sep 2017 08:48:26 PM UTC, comment #13: 

Okay, this works fine for me now.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 01 Sep 2017 06:29:25 PM UTC, comment #12: 

@Kai or Andre: Does the pdf show the output you expect?  Myself, I thought the commands between <latex>...</latex> would have been interpreted to result in a formula in the output.

Rik <rik5>
Group administrator
Fri 01 Sep 2017 06:04:48 PM UTC, comment #11: 

This is what I got running your test (attached).
I, personally, would prefer if we had a work-flow done through
pdf rather than eps
(by using e.g. pdflatexstabndalone print driver), but I
guess it is still a controversial subject.

Dmitri.
--




(file #41710)

Dmitri A. Sergatskov <dasergatskov>
Fri 01 Sep 2017 05:06:58 PM UTC, comment #10: 

In Fedora titlesec comes as a separate package...

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 01 Sep 2017 03:57:00 PM UTC, comment #9: 

How can I help test this and close this bug?

I tried creating pubtst.m with the following:


%% Headline title
%
% Some *bold*, _italic_, or |monospaced| Text with
% a <http://www.octave.org link to GNU Octave>.
%%

# "Real" Octave commands to be evaluated
sombrero ()

## Octave comment style supported as well
#
# * Bulleted list item 1
# * Bulleted list item 2
#
# # Numbered list item 1
# # Numbered list item 2

# <latex>
# Some output only visible in LaTeX or PDF reports.
# \begin{equation}
# e^x = \lim\limits_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)^{n}
# \end{equation}
# </latex>


I then executed


publish pubtst.m latex


This ran successfully, although it put things in a new directory 'html' when I thought it should be 'latex'.

Inside the 'latex' folder I see two files


pubtst-1.eps
pubtst.tex


So far so good.  How do I convert this to something like pdf so I can verify everything?

I tried


pdflatex pubtst


but I get an error and dropped in to an interactive shell.


! LaTeX Error: File `titlesec.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)



Rik <rik5>
Group administrator
Tue 29 Aug 2017 04:09:11 PM UTC, comment #8: 

I just uploaded a potential fix for all problems of this item: https://hg.savannah.gnu.org/hgweb/octave/rev/1a0cbb573a67

@Andre: Using the links of comment #3 the changes should be available for 4.2.1 as well.  Maybe you find the time to check if it now works as expected?  Thank you in advance.

Kai Torben Ohlhus <siko1056>
Group Member
Tue 22 Aug 2017 08:50:55 AM UTC, comment #7: 

Hello Andre,

My personal email is k.ohlhus@gmail.com. Don't hesitate to write and if it is relevant for other users, you can put the mailing list in the CC.

My intention with my mails is not to scare you away from Octave or using the publish function. I really appreciate, that you consider using it (maybe that piece got lost in my style of writing)! And if you are familiar with open source and maintain your own free software I am really happy to have contact with you. Most of Octave's users or "publish" users I will never hear of or get any feedback (good or "bad") from.

My comments were just generic "guidelines", as it was one of your first posts on that mailing-list. Occasionally, new members tent to catch attention to their problems by using every source of communication and catching up with wide spread information costs time. So please don't feel uncomfortable with writing about things you don't like or think can be improved with Octave or publish, which I really care about!

Regarding comment #6. I am glad to have improved that function a little and I try to fix 2) as well. So far I regular publish for HTML output, so testing of the LaTeX output was not ignored but not that intense that now changes thanks to you.

I will report about my progress here in the upcoming days.

Kai Torben Ohlhus <siko1056>
Group Member
Tue 22 Aug 2017 02:15:11 AM UTC, comment #6: 

Hello Kai,
I tried sending you a personal mail, but it was rejected.

First of all, thank you for your fixes. I completely understand the volunteering aspect of open source and it was not my intention to offend you or anyone by double posting.

When I posted the bug, I realized that I could try to narrow it down more by stepping through the code. When I found out more information, I wasn't sure whether posting this in the bug report or in the mail-list. I picked the latter in the hope it would be useful for reaching more people who then might provide some advice on how to fix it.

I have since learned the following:
1) publishing latex works best when surrounding the markup with <latex></latex> and as you pointed out, not use any blank lines in the markup. One can always use \newline.
2) $$ ... $$ notation does not work properly by itself, there are some issues with escaping '^' and '_'. Workaround is to enclose with <latex></latex>

cheers

andre <wienerschnitzel>
Mon 21 Aug 2017 04:58:59 PM UTC, comment #5: 

Thank you for fixing this so quickly.
I will give it a try tonight.

andre <wienerschnitzel>
Mon 21 Aug 2017 03:26:23 PM UTC, comment #4: 

I added a partial fix for the <latex> tag case (1. in comment #3):

https://hg.savannah.gnu.org/hgweb/octave/rev/58b76c741c3d

But it will only be available from the development versions (see the links in comment #3).

Kai Torben Ohlhus <siko1056>
Group Member
Mon 21 Aug 2017 12:52:45 PM UTC, comment #3: 

Thank you for your bug report.  Publish is pure m-code thus (mostly) platform independent ==> OS = Any.

Regarding the original submission: you did not exactly use the example from https://www.gnu.org/software/octave/doc/interpreter/LaTeX-Markup.html#LaTeX-Markup  as you added newlines into file #41566 (testpub.m).  I admit that this should be possible, but you are the first one who actually did this ;-)

Working on publish seems to me like fine tuning. There always show up documents like yours, I did not imagine to exist while writing the code.  And even using MATLAB's version did not always work for me out of the box and required some justifications in the output before further using it.  But I will improve two things on the development version:

1. Better recognition of blocks like "<html>" and "<latex>" without escaping the code.

2. Avoid escaping inside inline and block math.

Anyway, as you are using Octave 4.2, you can use the latest development versions of publish (all pure m-files) and replace the three major files with the latest versions, distributed in the next release:

https://hg.savannah.gnu.org/hgweb/octave/raw-file/tip/scripts/general/publish.m

https://hg.savannah.gnu.org/hgweb/octave/raw-file/tip/scripts/general/private/__publish_latex_output__.m

https://hg.savannah.gnu.org/hgweb/octave/raw-file/tip/scripts/general/private/__publish_html_output__.m

Kai Torben Ohlhus <siko1056>
Group Member
Sun 20 Aug 2017 06:19:03 PM UTC, comment #2: 

The problem happens in linux as well, although results are slightly different.
After building 4.2.1 from sources, the resulting latex does not compile with pdflatex in TexWorks.

octave:
GNU Octave Version: 4.2.1
GNU Octave License: GNU General Public License
Operating System: Linux 4.8.0-36-generic #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017 x86_64

I'm attaching m file and resulting tex file.

Please note that html output produces correctly (also attached)

I could not figure out how to change 'Operating System' in order to add 'Linux' - should I create new bug instead?


(file #41594, file #41595, file #41596)

andre <wienerschnitzel>
Fri 18 Aug 2017 07:12:36 AM UTC, comment #1: 

(not sure if the original submission can be edited)

the incorrect latex code got cut off towards the end, I must have made a mistake when pasting it; it should be:

e\^{}x = \lim\limits\_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)\^{}{n}


apologies

andre <wienerschnitzel>
Fri 18 Aug 2017 07:05:25 AM UTC, original submission:  

GNU Octave Version: 4.2.1
GNU Octave License: GNU General Public License
Operating System: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

using example as per octave publish webpage:
https://www.gnu.org/software/octave/doc/interpreter/LaTeX-Markup.html#LaTeX-Markup

I actually added a simple assignment at the beginning, otherwise the entire latex section gets ignored.

see attached file testpub.m and testpub.tex

publish("testpub.m","latex")
generates in testpub.tex which contains incorrect latex for the equation:

e\^{}x = \lim\limits\_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)\^{}{n}


above line of code does not compile, it should be:


e^x = \lim\limits_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)^{n}





andre <wienerschnitzel>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #41710:  pubtst.pdf added by dasergatskov (429KiB - application/pdf)
file #41594:  pubtest.m added by wienerschnitzel (85B - text/x-objcsrc)
file #41595:  pubtest.html added by wienerschnitzel (1KiB - text/html)
file #41596:  pubtest.tex added by wienerschnitzel (913B - text/x-tex)
file #41565:  testpub.tex added by wienerschnitzel (1019B - application/x-tex)
file #41566:  testpub.m added by wienerschnitzel (196B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by wienerschnitzel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-06 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2017-09-01 dasergatskov Attached File- Added pubtst.pdf, #41710
    2017-08-29 siko1056 StatusIn Progress Ready For Test
        Release4.2.1 dev
    2017-08-21 siko1056 StatusNone In Progress
    2017-08-21 siko1056 Assigned toNone siko1056
    2017-08-21 siko1056 Operating SystemMac OS Any
    2017-08-20 wienerschnitzel Attached File- Added pubtest.m, #41594
        Attached File- Added pubtest.html, #41595
        Attached File- Added pubtest.tex, #41596
    2017-08-18 wienerschnitzel Attached File- Added testpub.tex, #41565
        Attached File- Added testpub.m, #41566

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code