Is there anyway to write LaTex algorithm in sphinx-doc? - python-sphinx

I want to write algorithm in LaTeX in Sphinx-doc? Is there anyway to do so?

Yes. There is an extension sphinxcontrib-pseudocode that allows one to write LaTeX algorithm via algpseudocode LaTeX package syntax directly inside sphinx-doc. The extension is powered by pseudocode.js behind the scene.

Related

Set root path for relative links while converting with Pandoc

I have a markdown file which I want to convert into html file using pandoc.
It has some relative links in the form [text](relative_path.MD)
After conversion I want this links to lead to https://github.com/username/project/blob/master/relative_path.MD
In other words I want to set https://github.com/username/project/blob/master/ as a root for relative paths. Can I do this in some simple way?
I found that I can write arbitrary Lua filters, but surely I am not the first person trying to achieve this and there is some built-in method allowing to do this without writing own link parsing code?
Just came across this filter:
https://musteresel.github.io/posts/2018/01/pandoc-project-relative-links.html
It's in Haskell rather than Lua so won't be as efficient as a lua filter.
No idea if it works!

Rename latexmath macro in asciidoc

Is there a way I can rename or alias latexmath in an AsciiDoc document?
In an ideal world, I'd like to set up an AsciiDoc such that $...$ is interpreted as LaTeX math, and
$$...$$ is interpreted as a block equation. In general, I'm just trying to reduce the number of characters involved in defining a math block since
where $c$ is the speed of light and $m_0$ is the rest mass
is significantly more readable (to someone who's used LaTeX for years) than
where latexmath:[$c$] is the speed of light and latexmath:[$m_0$] is the rest mass
The use case I have is that I'm writing technical documentation for upload to a GitLab repository. I'd like to be able to exploit GitLab's ability to automatically render AsciiDoc format files. However, these documents are math heavy, so I find the large numbers of latexmath:[...] blocks hard to read while editing.
latexmath is the name of the macro that handles parsing the LaTeX markup. If you don't specify latexmath, asciidoctor doesn't know to pass control to an alternate parser.
You could achieve what you're after by writing a pre-processing step that identifies contiguous blocks of LaTeX markup and wraps that markup in latexmath:[...]. The updated markup can then be processed by Asciidoctor like normal (assuming that your LaTeX markup identification is accurate). How you go about implementing that is up to you.
Another way, assuming you have some Ruby skills, would be to modify the extension that implements the latexmath macro such that it was called, say, L. Then your markup would be the more concise:
where L:[$c$] is the speed of light and L:[$m_0$] is the rest mass

Can I use \input{file.tex} or similar to efficiently bring content (not a whole document) from a LaTeX file into a Jupyter notebook?

I am new to Jupyter notebooks and Python and have started using these to make materials for a workshop so that I can also produce a handout. I have useful content in various LaTeX files that I would like to include in a notebook.
I would like to know whether there is a command that will allow me to efficiently bring my already modularized content into a notebook. I will be happy to take suggestions on any approach to my problem in case the LaTeX route is the wrong way to proceed.
As a particular case, suppose an external file fig.tex has only a stand-alone tikzpicture (that I have successfully included in another LaTeX document). If I start a notebook code cell with
%%itikz and follow with \input{fig} I obtain error messages.
I can remedy the problem if I add a preamble with \documentclass{}, many necessary \usepackage{} and \usetikzlibrary{} commands (which I have already included at the top of the notebook), and wrap the content with begin/end document commands.
There is more manual handling here than I would like. Is there a more efficient way to include the tikzfigure content?
So it turns out with itikz you have an --implicit-pic option that fills in the preamble for you.
In principle, with this option, your cell would look like the following:
%%itikz --implicit-pic
% my awesome figure
\input{path/to/fig}
This creates a tex file populated like so:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.0]
% my awesome figure
\input{path/to/fig}
\end{tikzpicture}
\end{document}
In addition when using an implicit-pic it is usefull to load tikz packages and set options . To quote from the Quickstart guide:
In an --implicit-pic, it's often useful to:
Set the \tikzpicture[scale=X] via --scale=<X> while iterating.
Set the \usepackage{X,Y,Z} via --tex-packages=<X,Y,Z>
Set the \usetizlibrary{X,Y,Z} via --tiz-libraries=<X,Y,Z>
For more info, see items 16-20 in the Quickstart notebook.

Conversion between knitr and sweave

This might have been asked before, but until now I couldn't find a really helpful answer for me.
I am using R Studio with knitr and a colleague of mine who I need to cooperate with uses the sweave format. Is there a good way to convert a script back and forth between these two?
I have already found "Sweave2knitr" and hoped this would have an .rmd as output with all chunks changed (<<>> to {} etc.) but this is not the case. My main problem is that I would also need the option to convert from .rmd back to .rnw so that my colleague can also re-edit my work-over.
Thanks a lot!
To process the code chunks and convert the .Rnw file to .tex, you use the knit() function in the knitr package rather than Sweave().
R -e 'library(knitr);knit("my_file.Rnw")'
Sweave2knitr() is for converting old Sweave-based .Rnw files to the knitr syntax.
In Program defaults change :
Weave Rnw files using Sweave or knitr
The Rnw format is really LaTeX with some modifications, whereas the Rmd format is Markdown with some modifications. There are two main flavours of Rnw, the one used by Sweave being the original, and the one used by knitr being a modification of it, but they are very similar.
It's not hard to change Sweave flavoured Rnw to knitr flavoured Rnw (that's what Sweave2knitr does), but changing either one to Rmd would require extensive changes, and probably isn't feasible: certainly I'd expect a lot of manual work after the change.
So for your joint work with a co-author, I would recommend that you settle on a single format, and just use that. I would choose Rmd for this: it's much easier for your co-author to learn Markdown than for you to learn LaTeX. (If you already know LaTeX, that might push the choice the other way.)

reading and plotting txt file in autocad

I want to read a txt file in autocad and plot them (line/polyline).
it may looks like
1 x11 y11 z11.......x14, y14,z14 % polyline 1
..
n xn1 yn1 zn1.......xn4, yn4,zn4 % polyline n
I want to know what is best and easy way to do this. What programming language I should use.
What are useful links or is there somework already done in this direction.
Best regards,
No programming language required! Just create a text file and type AutoCAD commands in the file the same way you would at the AutoCAD command prompt. Save the file with the .scr extension and you can either drag the file onto the AutoCAD window, or use the script command in AutoCAD to find and run the command script.
More info: http://www.upfrontezine.com/tailor/tailor19.htm
I actually use Python to generate these command scripts. With the power of a modern language, and throwing in some AutoLisp, you can do surprisingly sophisticated things. I've used this to model a complex steel tower for a cablestay bridge, and for testing model geometry for Larsa modeling.
There are few ways you can do it.
Simple solution
Script file
Creating a script file is easier and quicker
http://docs.autodesk.com/MAP/2010/ENU/AutoCAD%20Map%203D%202010%20User%20Documentation/HTML%20Help/files/WS1a9193826455f5ff47b7aa4b11fbe75ecf1-65dc.htm
AutoLISP automation
This is also easier and quicker plenty of online resources available.
http://www.pixelgraphicsinc.com/AutoLisp_Tutorial01.html
Best but complicated solution
.NET C# plugin
This is the best option as it lets you do more than basic things.
If you like to do coding. This is fun. you can create a plugin using .NET C# and read the txt file to create the line segments.
Let me know how you go.
You can use ObjectARX in C# as well as C++.
C# will be a better choice.
Just read your text file using StreamReader using C# System.IO library.
Create a array of points specified in text file.
Finally create the Polyline using given points and Using Transient in ObjectARX you can display the Polyline.

Resources