LaTeX Bug: Identical Pictures with Different Code | Physics Forums

  • LaTeX
  • Thread starter Borek
  • Start date
  • Tags
    Bug Latex
In summary: Making software do the right thing given proper input is hard. For the most part, this site does do just that. (Occasionally we do get some weird database errors; those truly are bugs.) Making software do the right thing given improper input is extremely hard, an order of magnitude harder / more time-consuming compared to making software merely do the right thing given proper input.
Physics news on Phys.org
  • #2
Hi Borek! :smile:

I think it's the % symbol that wrecks the LaTeX :biggrin:

[tex]* 100%[/tex]

[tex]3SnF_{2}_{(aq)} + 2K_{3}PO_{4}_{(aq)} \rightarrow Sn(PO_{4})_{2}_{(s)} + 6KF_{(aq)}[/tex]

[tex](Actual yield)/(Theoretical yield) * 100%[/tex]

[tex](Actual yield)/(Theoretical yield) * 100[/tex]

[tex](Actual yield)/(Theoretical yield)[/tex]

[tex]* 100%[/tex]

[tex]* 100[/tex]​
 
  • #3
I found this in the online help of LaTeX (howtolatex.pdf) on PF:

"Special characters. The following symbols have special meaning in L TEX: # $ % _ { } ~ ^ \
You can print the first seven of these by using \# \$ \% \_ \{ \} ."

So:

[tex](Actual yield)/(Theoretical yield) * 100\%[/tex]

[edit]Not a bug![/edit]
 
  • #4
By my book it is a bug - if the code is invalid it should not yield correct, but different image.

I guess image was first generated OK, then message was edited and wrong code was entered, so new image was not generated, but old one WAS NOT DELETED.
 
  • #5
Borek said:
By my book it is a bug - if the code is invalid it should not yield correct, but different image.

I guess image was first generated OK, then message was edited and wrong code was entered, so new image was not generated, but old one WAS NOT DELETED.

So this would be a bug in the PF web server?
 
  • #6
In the PF script preparing LaTeX images.
 
  • #7
Borek said:
By my book it is a bug - if the code is invalid it should not yield correct, but different image.
There is a subtle misfeature here; it is the same one that forces us to refresh while generating a post that contains [ tex ] blocks. Whether this is a bug worthy of correction is a matter of opinion. Your book is not the same book that the owner of this site uses to make that distinction.

Making software do the right thing given proper input is hard. For the most part, this site does do just that. (Occasionally we do get some weird database errors; those truly are bugs.) Making software do the right thing given improper input is extremely hard, an order of magnitude harder / more time-consuming compared to making software merely do the right thing given proper input.

The right thing to do here is to make one of those "LaTeX generation failed" images such as those seen in post #2.


Is the correction offered by I like Serena in post #3 "correct"?

[tex](Actual yield)/(Theoretical yield) * 100\%[/tex]

My opinion: Yech. No space before yield, and the spacing in actualyield looks a lot more like the product of a, c, t, u, a, l, ... rather than words. Much better is

[tex]\mbox{(Actual yield)}/\mbox{(Theoretical yield)} * 100\%[/tex]

Or just (Actual yield)(Theoretical yield)} * 100%.
 
  • #8
D H said:
Making software do the right thing given proper input is hard. For the most part, this site does do just that. (Occasionally we do get some weird database errors; those truly are bugs.) Making software do the right thing given improper input is extremely hard, an order of magnitude harder / more time-consuming compared to making software merely do the right thing given proper input.

In 1979 (quite some time ago), the 6th commandment of Lint was formulated:

"6. If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest ``it cannot happen to me'', the gods shall surely punish thee for thy arrogance."

In short, it takes 2-3 times as much code to handle improper input.
I believe it usually is well worth the effort!
As I see it, the software of the TEX converter does handle improper input, yielding invalid-input images.
However the web server side script does not.

D H said:
Is the correction offered by I like Serena in post #3 "correct"?

[tex](Actual yield)/(Theoretical yield) * 100\%[/tex]

My opinion: Yech. No space before yield, and the spacing in actualyield looks a lot more like the product of a, c, t, u, a, l, ... rather than words. Much better is

[tex]\mbox{(Actual yield)}/\mbox{(Theoretical yield)} * 100\%[/tex]

Or just (Actual yield)(Theoretical yield)} * 100%.

No argument there - I agree!
[edit]Minus the misplaced '/' and '}' ;-)[/edit]
 
  • #9
I like Serena said:
In short, it takes 2-3 times as much code to handle improper input.
If only it were that simple. Even if it was that simple, that still represents a huge cost overhead.

There are times when the even recognizing that the input is improper is extremely hard, if not downright impossible. Some examples:
  • Having the compiler determine whether a program halts. First off, there's the halting problem that makes answering this question a bit more than problematic. Secondly, what if the program isn't supposed to halt? Is halting an error? (In many cases, yes it is.)
  • Having the compiler determine whether a variable is assigned a value before the variable is accessed. This is equivalent to the halting problem.
  • Having a C compiler make sense of i = 5; printf ("%d\n", (i++)*i); The result might be to print 36. Or it might print 25, or 30, or 1234567890. Then it might result in a call reformat_hard_drive() or even eject_nasal_demons(). All are valid responses to such nonsense.

There is no way to anticipate all the goofy ways users can get things wrong. We can try, and trying is a "good thing", but there are no guarantees.
 
  • #10
D H said:
Making software do the right thing given proper input is hard. For the most part, this site does do just that. (Occasionally we do get some weird database errors; those truly are bugs.) Making software do the right thing given improper input is extremely hard, an order of magnitude harder / more time-consuming compared to making software merely do the right thing given proper input.

To put things in a perspective - I am earning my living selling software I wrote. I know it is difficult to make completely foolproof software, I never claimed my software is 100% foolproof (quite the opposite - now and then I am shown it is not). Still, it doesn't stop me from trying to make it as foolproof as possible.
 
  • #11
Right, but you are doing it for profit. I also write scientific software, and I do do my best to make it foolproof. There is however a huge cost in doing so -- and even then I care a whole lot more about whether our software works correctly given correct input than I care about how our software works in the face of goofy input.

Greg is doing this for fun, and mostly for free. If physicsforums.com did generate all of or even a significant fraction of Greg's income we would have a significantly increased case here.
 
  • #12
D H said:
Right, but you are doing it for profit. I also write scientific software, and I do do my best to make it foolproof. There is however a huge cost in doing so -- and even then I care a whole lot more about whether our software works correctly given correct input than I care about how our software works in the face of goofy input.

Allocation of resources devoted to making program foolproof probably depends on the intended audience and their expected level of computer competence. I must assume I wrote for complete idiots Even then I am sometimes overestimating their knowledge - https://www.physicsforums.com/showthread.php?p=3184107#post3184107

Greg is doing this for fun, and mostly for free. If physicsforums.com did generate all of or even a significant fraction of Greg's income we would have a significantly increased case here.

Totally agreed. But it shouldn't stop us from pointing out errors :wink:
 
  • #13
D H said:
If only it were that simple. Even if it was that simple, that still represents a huge cost overhead.

There are times when the even recognizing that the input is improper is extremely hard, if not downright impossible. Some examples:
  • Having the compiler determine whether a program halts. First off, there's the halting problem that makes answering this question a bit more than problematic. Secondly, what if the program isn't supposed to halt? Is halting an error? (In many cases, yes it is.)
  • Having the compiler determine whether a variable is assigned a value before the variable is accessed. This is equivalent to the halting problem.
  • Having a C compiler make sense of i = 5; printf ("%d\n", (i++)*i); The result might be to print 36. Or it might print 25, or 30, or 1234567890. Then it might result in a call reformat_hard_drive() or even eject_nasal_demons(). All are valid responses to such nonsense.

There is no way to anticipate all the goofy ways users can get things wrong. We can try, and trying is a "good thing", but there are no guarantees.

These are exactly the reasons why programs like Lint were invented, and why compilers have advanced warning capabilities.
The points you mention are reported by Lint as warnings, and I believe modern compilers will report them too.

It is up to the programmer to ignore these warnings, but if he doesn't, his program will become mostly foolproof.

Furthermore we have coding standards.
Afaik the http://www.codingstandard.com/HICPPCM/index.html" is fast becoming the de facto standard for C++.
Again your program will become mostly foolproof-er if you abide by this standard.
And you'll need a code checker tool to tell you if you do.

Current safety-engineering standards (SIL) require that you adhere to such a standard and have tools in place to verify it.
 
Last edited by a moderator:
  • #14
Borek said:
Allocation of resources devoted to making program foolproof probably depends on the intended audience and their expected level of computer competence. I must assume I wrote for complete idiots Even then I am sometimes overestimating their knowledge - https://www.physicsforums.com/showthread.php?p=3184107#post3184107

Nice one .

So did the customer get his money back?
 
  • #15
I like Serena said:
Nice one .

So did the customer get his money back?

Yes. It is much faster and easier to swallow the loss than to argue with people who have no idea what they are doing.
 

Related to LaTeX Bug: Identical Pictures with Different Code | Physics Forums

What is LaTeX and why is it used?

LaTeX is a typesetting system used for creating professional-looking documents, especially in the fields of mathematics, computer science, and other sciences. It is popular among scientists because it allows for precise formatting and handling of equations and symbols.

What is a LaTeX bug?

A LaTeX bug refers to an error or unexpected behavior in the LaTeX software that causes issues with document formatting or compiling. These bugs can be caused by coding errors, compatibility issues, or other technical problems.

How do I report a LaTeX bug?

If you encounter a LaTeX bug, you can report it to the developers through their official website or forums. Before reporting a bug, it is important to provide a clear and concise description of the issue, along with any necessary code or files that can help the developers reproduce the bug.

How are LaTeX bugs fixed?

LaTeX bugs are typically fixed by the developers through software updates. These updates may be released periodically or on an as-needed basis, depending on the severity of the bug. Users can check for updates and download them to fix any known bugs in their LaTeX software.

Can I fix a LaTeX bug myself?

If you are familiar with coding and have the necessary technical skills, you may be able to fix a LaTeX bug yourself. However, it is recommended to report the bug to the developers and let them handle the fix, as they have a better understanding of the software and its code.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
975
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • Feedback and Announcements
Replies
5
Views
379
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
Back
Top