Share Latex Code Easily: Tips and Tricks

  • Context: LaTeX 
  • Thread starter Thread starter PainterGuy
  • Start date Start date
  • Tags Tags
    Code Latex
Click For Summary

Discussion Overview

The discussion revolves around sharing LaTeX code generated from Scientific Workplace (SW) in a format suitable for the Physics Forums. Participants explore methods to convert and present mathematical equations clearly, addressing challenges related to formatting and sharing code effectively.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant describes their use of Scientific Workplace for writing mathematical documents and expresses difficulty in sharing work effectively on the forum.
  • Another participant suggests writing equations directly in LaTeX format, providing an example of how to format the equations for clarity.
  • Several participants mention the importance of using the correct delimiters for LaTeX, noting that double pound signs (##) are used for inline math and double dollar signs ($$) for display math on the forum.
  • A participant shares their experience of modifying the LaTeX code generated by SW to improve its presentation, indicating that they replaced certain characters and tags to make it more forum-friendly.
  • Another participant points out that the conversion process may introduce errors and suggests that posting images might be a simpler solution if the LaTeX code remains problematic.
  • Some participants recommend online LaTeX editors and viewers, sharing links to resources that could assist in editing and visualizing LaTeX code.
  • There are mentions of specific issues with the LaTeX code generated by SW, including incorrect commands and formatting that may not render properly in the forum.

Areas of Agreement / Disagreement

Participants express a range of views on the best methods for sharing LaTeX code, with some advocating for direct writing in LaTeX while others highlight the challenges of converting from SW. There is no consensus on a single best approach, as participants continue to explore various solutions and share experiences.

Contextual Notes

Some participants note that the LaTeX code generated by Scientific Workplace may contain errors or formatting issues that complicate sharing. There are also discussions about the limitations of the forum's support for different LaTeX commands and the potential for confusion when converting code.

Who May Find This Useful

This discussion may be useful for users of Scientific Workplace looking to share their LaTeX code on forums, as well as those interested in learning about formatting mathematical expressions for online platforms.

PainterGuy
Messages
938
Reaction score
73
Hi

I use Scientific Workplace to write down math equations and also to create documents involving mathematics and to do calculations. Although most people use it for writing science articles, I've found it extremely helpful for whatever little bit of mathematics I do.

I face a problem when I need to share my work with someone, say, on this forum. Mostly I take a screenshot of my work and share it like this. But I can imagine that it's not easy for a person who is trying to help me to correct any error in my calculations or to point out a certain fragment or equation from the screenshot. What can I do to make it little easier and convenient for others? The software can produce xHTML page too but the forum doesn't support the format. When I try to copy the latex code for the linked screenshot, I get the following which doesn't make much sense and I don't know how to put into proper latex form so it can be made work here.

Code:
038<p type="texpara" tag="Body Text" >$\U{394} P=\frac{8\U{3bc} LQ}{\U{3c0} R\U{2074} }$
   
038<p type="texpara" tag="Body Text" >$\U{394} P$ is the pressure difference between the two ends
   
038<p type="texpara" tag="Body Text" >$L$ is the length of pipe, $1$ $km$
   
038<p type="texpara" tag="Body Text" >$\U{3bc} $ is the dynamic viscosity,  $8.90\times 10^{-4}$ $Pa$\textperiodcentered $s$
   
038<p type="texpara" tag="Body Text" >$Q$ is the volumetric flow rate, $2m^{3}/s$
   
038<p type="texpara" tag="Body Text" >$R$ is the pipe radius, $0.2m$
   
038<p type="texpara" tag="Body Text" >
   
038<p type="texpara" tag="Body Text" >$\U{394} P=\frac{8\U{3bc} LQ}{\U{3c0} R\U{2074} }=\frac{8\ast 8.90\times 10^{-4}\ast 997.6\ast 2}{\U{3c0} \ast 0.2^{4}}=\allowbreak \frac{8878.\,\allowbreak 6}{\U{3c0} }=2826$ $Pa$

Please let me know that how I can make it little easier for others. Thank you.
 
Physics news on Phys.org
You could simply write it out like this:

##\Delta P=\dfrac{8\mu LQ}{\pi R^4 }##

##\Delta P## is the pressure difference between the two ends

##L## is the length of pipe, ##1\text{ km}##

##\mu ## is the dynamic viscosity, ##8.90\times 10^{-4}\text{ Pa}\cdot\text{s}##

##Q## is the volumetric flow rate, ##2\,\dfrac{\text{m}^3}{\text{s}}##

##R## is the pipe radius, ##0.2\text{ m}##



##\Delta P=\dfrac{8\mu LQ}{\pi R^4 }=\dfrac{8\cdot 8.90\times 10^{-4}\cdot 997.6\cdot 2}{\pi \cdot 0.2^{4}}=\dfrac{8878.6}{\pi}=2826 \text{ Pa}##

Quote my post to see the difference between what you have in Scientific Workplace and what I posted above.
 
  • Like
Likes   Reactions: PainterGuy
MarkFL said:
You could simply write it out like this:

##\Delta P=\dfrac{8\mu LQ}{\pi R^4 }##

##\Delta P## is the pressure difference between the two ends

##L## is the length of pipe, ##1\text{ km}##

##\mu ## is the dynamic viscosity, ##8.90\times 10^{-4}\text{ Pa}\cdot\text{s}##

##Q## is the volumetric flow rate, ##2\,\dfrac{\text{m}^3}{\text{s}}##

##R## is the pipe radius, ##0.2\text{ m}##



##\Delta P=\dfrac{8\mu LQ}{\pi R^4 }=\dfrac{8\cdot 8.90\times 10^{-4}\cdot 997.6\cdot 2}{\pi \cdot 0.2^{4}}=\dfrac{8878.6}{\pi}=2826 \text{ Pa}##

Quote my post to see the difference between what you have in Scientific Workplace and what I posted above.

Thank you.

I believe that you typed it out again here. The problem is that it would just require me re-type everything and it would leave Scientific Workplace (SW) useless as far as just writing down a document goes. Do you see any easy way to fix my SW code so that I could just share it? Thanks.
 
Right click on equation, select "show math as" and then choose tex commands.
 
  • Like
Likes   Reactions: PainterGuy
PainterGuy said:
Thank you.

I believe that you typed it out again here. The problem is that it would just require me re-type everything and it would leave Scientific Workplace (SW) useless as far as just writing down a document goes. Do you see any easy way to fix my SW code so that I could just share it? Thanks.

I copy/pasted what you included in the CODE box into a text editor (Notepad++), and then used the replace function to remove the leading "038" and the opening HTML paragraph tag. Then I replaced the \U{xxx} characters with the equivalent ##\LaTeX## symbols, and a few other minor adjustments.

I think the main difference is that in your work environment dollar signs are used as delimiters, whereas here double pound signs are used. You may get away with simply replacing those, as I suspect the other things were a result of you copying HTML rather than your raw text.
 
  • Like
Likes   Reactions: PainterGuy
MarkFL said:
I think the main difference is that in your work environment dollar signs are used as delimiters, whereas here double pound signs are used.
Double pound for inline, double dollar sigh for new line.
 
  • Like
Likes   Reactions: MarkFL
Greg Bernhardt said:
Double pound for inline, double dollar sigh for new line.

Ah...I noticed the TEX tags also serve as display type delimiters. Double dollar is easier...thanks!
 
MarkFL said:
Ah...I noticed the TEX tags also serve as display type delimiters. Double dollar is easier...thanks!
Right tex and itex
 
  • #10
Thank you, everyone.

I use Scientific Workplace 5.50 but just downloaded SW 6 to experiment with it. The latex code below was generated by SW 6 and I just replaced "$" with ""##" using Notepad++. It looks a little better compared to the previous one. I believe that it'd make a little easier for others.

Do you know of any free online latex viewer and editor? I found this https://latexbase.com/ which isn't really working for me. Thanks.

##\Delta P =\frac{8 \mu L Q}{\pi R {\small\fbox{2074}} }##

##\Delta P## is the pressure difference between the two ends

##L## is the length of pipe, ##1## ##k m##

##\mu ## is the dynamic viscosity, ##8.90 \times 10^{ -4}## ##P a##{\textperiodcentered}##s##

##Q## is the volumetric flow rate, ##2 m^{3}/s##

##R## is the pipe radius, ##0.2 m##

##\Delta P =\frac{8 \mu L Q}{\pi R {\small\fbox{2074}} } =\frac{8 \ast 8.90 \times 10^{ -4} \ast 997.6 \ast 2}{\pi \ast 0.2^{4}} =\frac{8878.\,6}{\pi } =2826## ##P a##
 
  • #12
PainterGuy said:
The latex code below was generated by SW 6 and I just replaced "$" with ""##" using Notepad++. It looks a little better compared to the previous one. I believe that it'd make a little easier for others.
The conversion to TEX doesn’t seem like it will help you much since it’s introducing several problems itself. Unless you can copy and modify the raw code for the original you are working on, posting a picture like you first mentioned is probably your best bet.
 
  • Like
Likes   Reactions: PainterGuy
  • #13
PainterGuy said:
Thank you, everyone.

I use Scientific Workplace 5.50 but just downloaded SW 6 to experiment with it. The latex code below was generated by SW 6 and I just replaced "$" with ""##" using Notepad++. It looks a little better compared to the previous one. I believe that it'd make a little easier for others.

Do you know of any free online latex viewer and editor? I found this https://latexbase.com/ which isn't really working for me. Thanks.

##\Delta P =\frac{8 \mu L Q}{\pi R {\small\fbox{2074}} }##

##\Delta P## is the pressure difference between the two ends

##L## is the length of pipe, ##1## ##k m##

##\mu ## is the dynamic viscosity, ##8.90 \times 10^{ -4}## ##P a##{\textperiodcentered}##s##

##Q## is the volumetric flow rate, ##2 m^{3}/s##

##R## is the pipe radius, ##0.2 m##

##\Delta P =\frac{8 \mu L Q}{\pi R {\small\fbox{2074}} } =\frac{8 \ast 8.90 \times 10^{ -4} \ast 997.6 \ast 2}{\pi \ast 0.2^{4}} =\frac{8878.\,6}{\pi } =2826## ##P a##

Are you actually writing the LaTeX, or is Scientific Workplace generating it? Because some of your LaTeX is simply incorrect. \textperiodcentered should not appear in mathmode. The correct command is much simpler: \cdot. Also, I'm not sure where \small\fbox{2074} came from. From the image you shared earlier, it looks like you just want to raise R to the fourth power, which should just be R^4.

You need to be using the commands from the amsmath package, as that is standard, and what is implemented (mostly) on PF.
 
  • Like
Likes   Reactions: PainterGuy and stoomart
  • #14
Hey, PainterGuy!
I don't really have anything useful to contribute regarding your question, but I just wanted to touch base as a fellow SWP 5.5 user. I use it all the time, for almost everything I write which is all day almost every day. It is great software, and the support services are great as well.
 
  • Like
Likes   Reactions: PainterGuy
  • #15
Ben Niehoff said:
Are you actually writing the LaTeX, or is Scientific Workplace generating it? Because some of your LaTeX is simply incorrect. \textperiodcentered should not appear in mathmode. The correct command is much simpler: \cdot. Also, I'm not sure where \small\fbox{2074} came from. From the image you shared earlier, it looks like you just want to raise R to the fourth power, which should just be R^4.

Thank you.

It was generated by SW 6.
 
  • #16
Hi,

Whenever I try to quote a post which uses latex, the quoted post doesn't compile the code. For example, I tried to quote some parts of this post here but it doesn't work.

Could you please help me to resolve this issue?

Thank you!
 
  • #17
PainterGuy said:
Could you please help me to resolve this issue?
highlight-to-quote won't copy the latex because there is underlying code the browser doesn't pickup. You need to click the "reply" link at the end of a post.
 
  • Like
Likes   Reactions: SammyS and PainterGuy

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K