How to refer to an equation in Sphinx - python-sphinx

I have an equation written in a rst file as:
.. math::
F=\begin{bmatrix} \lambda_1 & 0 & 0\\0 & \lambda_2 & 0\\0 & 0 & \lambda_3\end{bmatrix}
:label: eq:6
It is shown perfectly as:
Now I want to refer to this equation in the same rst file. I tried somwthing like:
I need to refer to this :ref:`Link title < eq:6>`
However it did not work. How can I link (e.g. refer) to this equation?

You have mismatched indentation for your math role, an incorrect role option of label instead of name, incorrect ordering of role and its content, and an extra space after the < in your link reference.
The following works for me.
.. math::
:name: eq:6
F=\begin{bmatrix} \lambda_1 & 0 & 0\\0 & \lambda_2 & 0\\0 & 0 & \lambda_3\end{bmatrix}
I need to refer to this :ref:`Link title <eq:6>`
There is another reference to :math:numref:, but I do not think that is what you want. There is also the use of ref where one can use a label as the target of the ref.

Related

Label Expression Frustration

I have a two label fields, [field1] & [field2] I want to display on my map.
I want them to be on two separate lines with the bottom one in bold and in a different color and adding mg/L after the value. The bottom label also needs to all fit on one line despite it being too long, arcmap is currently separating them. I have only written this much:
"" & [field1] & "" & vbnewline & "" & FormatNumber(Round( [field2] , 0),0) & " mg/L" & ""
When I add more I cant seem to get it right and lots of errors come up.
Sorry for late reply, Try to put your field2 text in these tags in label expression it will change the color and will bold your text
"<BOL>"& "<CLR red= '100'>" & [field2] & "</CLR>"&"</BOL>"
something like:
"" & [field1] & "" & vbnewline & "<BOL>"&"<CLR red= '100'>" & FormatNumber(Round( [field2] , 0),0) & " mg/L" & "</CLR>"&"</BOL>"

Eliminate matrix header in esttab (latex) or outtable output

I have a matrix of values (very non-standard summary statistics) that I want to pass from Stata to LaTeX. The command:
esttab matrix(matname) using $myfilename.tex, replace booktabs f
gives the matrix in LaTeX form but also gives the title of the matrix within the fragment. The same is true for:
outtable using myfilename, mat(matname) replace nobox
Currently, every time I rerun my Stata do file I have to go and edit myfilename.tex by hand.
Is there any way to non-manually remove the matrix name from the Stata to LaTeX output?
I tried using the option noheader, which works here:
matrix list matname, noheader
but doesn't seem to be active in esttab or outtable. It also occurred to me that if I could find a way to ask LaTex to just \input PART of the fragment file (lines 2 onward) that would work...
I think the nomtitles option will work. Here's reproducible example:
sysuse auto
reg price trunk headroom
matrix myMat = e(V)
esttab matrix(myMat) using temp.tex, replace booktabs f nomtitles
This produces the text (.tex) file below:
& trunk& headroom& \_cons\\
\midrule
trunk & 10557.96& -35339.31& -39464.18\\
headroom & -35339.31& 269901.5& -321726.7\\
\_cons & -39464.18& -321726.7& 1612951\\
Also, I used the following outtable command
outtable using "./temp", mat(myMat) replace center f(%9.2f) nobox
to produce this output:
% matrix: myMat file: ./temp.tex 10 Jun 2016 12:55:35
\begin{table}[htbp]
\begin{tabular}{lccc} \hline \hline
& trunk & headroom & cons \\ \hline
trunk & 10557.96 \\
headroom & -35339.31 & 269901.52 \\
cons & -39464.18 & -3.22e+05 & 1.61e+06 \\
\hline \hline \end{tabular}
\end{table}
While the matrix name is present in the output, it is commented out and so will not appear in the latex document.

Reading and writing an INI file

I have been toying with the below script to be able to read settings for use with my HTA (creating a game launcher).
Here is my current HTA:
http://pastebin.com/skTgqs5X
It doesn't quite work, it complains of the WScript object being required. While I understand Echo will not work like that in a HTA I am having trouble modifying the code so it will work. Even just removing all Echo references it still has an issue with objOrgIni on line 200 of the below code (with the WScript references removed):
http://pastebin.com/pGjv4Gh1
I don't even need that level of error checking as the INI will exist etc, I just need a simple way to read from and write to an INI in my scripting. Any help you guys can give me in achieving that would be great, it's a little advanced for me just yet, but I'd love an explanation as to why it fails.
There is no easy way to use INI files with VBScript. You'd have to write the functionality yourself or find some existing code that does it.
But do you really need an INI specifically or just a way to save settings? You could just keep all of your settings in a Dictionary object and serialize it as needed.
For example, here are two functions -- LoadSettings and SaveSettings -- that do just that.
Public Function LoadSettings(strFile)
Set LoadSettings = CreateObject("Scripting.Dictionary")
Dim strLine, a
With CreateObject("Scripting.FileSystemObject")
If Not .FileExists(strFile) Then Exit Function
With .OpenTextFile(strFile)
Do Until .AtEndOfStream
strLine = Trim(.ReadLine())
If InStr(strLine, "=") > 0 Then
a = Split(strLine, "=")
LoadSettings.Add a(0), a(1)
End If
Loop
End With
End With
End Function
Sub SaveSettings(d, strFile)
With CreateObject("Scripting.FileSystemObject").CreateTextFile(strFile, True)
Dim k
For Each k In d
.WriteLine k & "=" & d(k)
Next
End With
End Sub
Imagine you had the following settings file saved at c:\settings.txt:
Count=2
Name=Obama
You'd use the functions above like this:
Const SETTINGS_FILE = "c:\settings.txt"
Dim Settings
Set Settings = LoadSettings(SETTINGS_FILE)
' Show all settings...
WScript.Echo Join(Settings.Keys, ", ") ' => Count, Name
' Query a setting...
WScript.Echo Settings("Count") ' => 2
' Update a setting...
Settings("Count") = Settings("Count") + 1
' Add a setting...
Settings("New") = 1
' Save settings...
SaveSettings Settings, SETTINGS_FILE

Remove numbers at specific position in String VBScript

I have strings like these -
CRS|R|S||3.0|25|W||U||||0||ECN|211|MACROECONOMIC PRINCIPLES
CRS|R|S||3.0|25|F||U||||0||CIS|105|SURVEY COMPUTER INFO SYSTEMS
CRS|R|S||3.0|25|A||U||||12||CSR|207|AUTOMOBILE POLICY ADJUSTMENT
The format of these will always be like this.
I want to remove any numbers just before ECN, CIS or CSR above.
So after processing, my output should look like this -
CRS|R|S||3.0|25|W||U||||||ECN|211|MACROECONOMIC PRINCIPLES
CRS|R|S||3.0|25|F||U||||||CIS|105|SURVEY COMPUTER INFO SYSTEMS
CRS|R|S||3.0|25|A||U||||||CSR|207|AUTOMOBILE POLICY ADJUSTMENT
0 and 12 are removed from the strings above.
Please note - ECN, CIS or CSR are just for example. It can be anything. I want to remove the numbers before these 3 letters.
Please help me out !
Try Split on the |, emptying the value at the appropriate position, and then Join back together with the |.
Option Explicit
Dim input
Dim lines, ub, i, lineParts
Dim output
input = "CRS|R|S||3.0|25|W||U||||0||ECN|211|MACROECONOMIC PRINCIPLES" & vbCrLf & _
"CRS|R|S||3.0|25|F||U||||0||CIS|105|SURVEY COMPUTER INFO SYSTEMS" & vbCrLf & _
"CRS|R|S||3.0|25|A||U||||12||CSR|207|AUTOMOBILE POLICY ADJUSTMENT"
lines = Split(input, vbCrLf)
ub = UBound(lines)
For i = 0 To ub
lineParts = Split(lines(i), "|")
lineParts(12) = ""
lines(i) = Join(lineParts, "|")
Next
output = Join(lines, vbCrLf)

Rotated table in Latex appears at the end of the file

Any table I define with "sidewaystable" appears at the last page of created pdf file. How can I solve this?
\begin{sidewaystable}[h]
\caption{Blah Measurements}
\centering % centering table
\begin{tabular}{c c c c c c c c c c}
\hline\hline % inserting double-line
A & B & \multicolumn{3}{c}{C} & C Time + & D & \multicolumn{3}{c}{D Signal} \\
ID & ID & \multicolumn{3}{c}{Coordinates} & Time Diff. & Time & \multicolumn{3}{c}{Parameters} \\ [0.5ex]
\hline % inserts single-line
1 & 1 & 4415633.126837 & 482211.909079 & 939.450000 & 06:07:40 & 06:07:40 & -85 dBm & 6 dB & 5 dBm \\
\hline
\end{tabular}
\label{tab:combined}
\end{sidewaystable}
Have you tried the something like htbp for the placement of the float object?
\begin{sidewaystable}[htbp]
...
\end{sidewaystable}
Just use \clearpage \newpage before \begin{sidewaystable} and \clearpage after the \end{sidewaystable}..
It works without any floats like H, h!, htpb, etc.
you can try and use \begin{table}[h!] -- the ! will try and tell latex to force your table into the exact spot. I've had hit or miss results.
Also, with the float package, you can use a capital H \begin{table}[H] to keep your table from floating.

Resources