How to have double backslash `\\` in vscode snippet - visual-studio-code

I want to get this snippet to work :
"General matrix": {
"prefix": "general-matrix-n-n-with-a-elements",
"body": [
"\\begin{equation}",
"\t \\begin{bmatrix}",
"\t\t a_{11} & a_{12} & a_{13} & \\dots & a_{1n} \\\\ ",
"\t\t a_{21} & a_{22} & a_{23} & \\dots & a_{2n} \\\\ ",
"\t\t \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\ ",
"\t\t a_{n1} & a_{n2} & a_{n3} & \\dots & a_{nn}",
"\t \\end{bmatrix}",
"\\end{equation}",
],
"description": "General n by n matrix"
So that it formats to this
\begin{equation}
\begin{bmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n} \\
a_{21} & a_{22} & a_{23} & \dots & a_{2n} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & a_{n3} & \dots & a_{nn}
\end{bmatrix}
\end{equation}
But the backslashes are formatting to this
\begin{equation}
\begin{bmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n} \
a_{21} & a_{22} & a_{23} & \dots & a_{2n} \
\vdots & \vdots & \vdots & \ddots & \vdots \
a_{n1} & a_{n2} & a_{n3} & \dots & a_{nn}
\end{bmatrix}
\end{equation}
Note that there's not a double \\ at the end of the lines but a single \

Just add two more backslashes as in:
"General matrix": {
"prefix": "general-matrix-n-n-with-a-elements",
"body": [
"\\begin{equation}",
"\t \\begin{bmatrix}",
"\t\t a_{11} & a_{12} & a_{13} & \\dots & a_{1n} \\\\\\ ",
"\t\t a_{21} & a_{22} & a_{23} & \\dots & a_{2n} \\\\\\ ",
"\t\t \\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\\ ",
"\t\t a_{n1} & a_{n2} & a_{n3} & \\dots & a_{nn}",
"\t \\end{bmatrix}",
"\\end{equation}",
],
"description": "General n by n matrix"
}
Each backslash in a snippet that you want printed needs to be double-escaped, so that is 2 extra per each backslash for a total of 6 if you want 2 outputted.

Related

Matrix second order interpolation

I have the following matrix
$$\begin{bmatrix}
k_{11}(y_1) & k_{12} (y_2) & \hdots & k_{1N_S} (y_{N_S}) \\
k_{21}(y_2) & \ddots & & \vdots \\
\vdots & & \ddots & \vdots \\
k_{N_S1}(y_{N_S}) & \hdots & \hdots & k_{N_SN_S} (y_{N_S})
\end{bmatrix}$$
where each element is computed at a point in a non-uniform mesh $y_j$, $j=1,\hdots, N_S$
I want to interpolate this matrix (second order) to a new mesh, say $z_j$, $j=1,\hdots, N_D$, with $N_D<N_S$, so that the new matrix will be
$$\begin{bmatrix}
k^*_{11}(z_1) & k^*_{12} (z_2) & \hdots & k^*_{1N_D} (z_{N_D}) \\
k^*_{21}(z_2) & \ddots & & \vdots \\
\vdots & & \ddots & \vdots \\
k^*_{N_S1}(z_{N_D}) & \hdots & \hdots & k^*_{N_DN_D} (z_{N_D})
\end{bmatrix}$$
where $k^*_{ij}$ are the corresponding interpolated values of $k_{ij}$.
How can I do this in MATLAB?

VBscript - Body of text file into Email

i m using the following script to send a few emails during the day, it takes one or more parameters (there are a few versions) and is called by a .bat file. The script is :
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 2
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Dim sDateTimeStamp
Set args = WScript.Arguments
arg1 = args(0)
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "myemail#gmail.com" ' or "Sender Name <from#gmail.com>"
oMsg.To = "otheremail#gmail.com" ' or "Recipient Name <to#gmail.com>"
oMsg.Subject = "System Message"
oMsg.BodyPart.Charset = "Windows-1253"
oMsg.Textbody = "Attached files." & vbcrlf & _
"This on a new line" & vbcrlf & _
"This on yet another"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const FileToBeUsed = "DIRTEST.TXT"
Dim fso, f, g
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(FileToBeUsed, ForReading)
g = f.ReadAll
f.Close
Set f = Nothing
Set fso = Nothing
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "gmail.com" 'server address
oConf.Fields(schema & "smtpserverport") = 587 'port number
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic 'authentication type
oConf.Fields(schema & "smtpusessl") = False 'use SSL encryption
oConf.Fields(schema & "sendusername") = "mymy#gmail.com" 'sender username
oConf.Fields(schema & "sendpassword") = "XXXXXX" 'sender password
oConf.Fields.Update()
'base64
' send message
oMsg.Send()
' Return status message
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Success Notification Message sent succesfully."
End If
Wscript.echo(resultMessage)
Right now the text body is set to :
Attached Files
This is a new line
This is yet another
I would like to interject a directory listing between line 1 and 2, either directly or by saving the directory listing in a text file, then putting the contents of said file in the email body, like so :
Attached Files
06/10/2016 <TIME> 13.000 Name1.txt
06/10/2016 <TIME> 300.000 Name2.pdf
06/10/2016 <TIME> 150.000 Name3.pdf
06/10/2016 <TIME> 5.000.000 Name4.pdf
This is a new line
This is yet another
EDIT : The above code succesfully appends the dir list to the mail subject, but also appends a batch of gibberish characters at the top.
The script is self explanatory
Edit: Formated size. Also note it give the size of folders. This can be slow, you may want to omit for folders. For instance the first time you run above code (on c:\ folder) windows has to read every folder into memory. That takes a while. Second time you run it all folders will be in the disk cache and it will be super fast.
Edit2 The VBS help file has recently been taken down at MS web site. It is available on my skydrive at https://1drv.ms/f/s!AvqkaKIXzvDieQFjUcKneSZhDjw It's called script56.chm.
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set fldr = fso.GetFolder("c:\")
Set Fls = fldr.files
Set Fldrs = fldr.subfolders
For Each thing in Fls
A= A & vbtab & thing.name & vbtab & thing.attributes & vbtab & FormatNumber(thing.size, 0) & vbtab & Thing.DateLastModified & vbcrlf
Next
For Each thing in Fldrs
A= A & vbtab & thing.name & vbtab & thing.attributes & vbtab & FormatNumber(thing.size, 0) & vbtab & Thing.DateLastModified & vbcrlf
Next
msgbox a
msgbox a

seems that mathtype doesn't parse a simple amsmath code or maybe the formula is too big to be processed by mathtype at once?

I want to create something like this in MS Word by MathType 6.9
The code that I'm using is:
\documentclass[a4paper]{book}
\usepackage{geometry}
\usepackage{amsmath}
\begin{document}
\begin{align}
T_4 &= \langle \underline{k}\,.\,\underline{k}^{*^T} \rangle=
\left\langle
\begin{bmatrix}
\left|k_1\right|^2 & k_1k_2^* & k_1k_3^* & k_1k_4^* \\
k_2k_1^* & \left|k_2\right|^2 & k_2k_3^* & k_2k_4^* \\
k_3k_1^* & k_3k_2^* & \left|k_3\right|^2 & k_3k_4^* \\
k_4k_1^* & k_4k_2^* & k_4k_3^* & \left|k_4\right|^2
\end{bmatrix}
\right\rangle
\\
&=\frac{1}{2}
\begin{aligned}[t]
& \left[\begin{matrix}
\langle|S_{XX}+S_{YY}|^2\rangle &
\langle(S_{XX}+S_{YY})(S_{XX}-S_{YY})^*\rangle &\\
\langle(S_{XX}-S_{YY})(S_{XX}+S_{YY})^*\rangle &
\langle|S_{XX}-S_{YY}|^2\rangle & \cdots\cdots\\
\langle(S_{XY}+S_{YX})(S_{XX}+S_{YY})^*\rangle&
\langle(S_{XY}+S_{YX})(S_{XX}-S_{YY})^*\rangle & \cdots\cdots\\
\langle j(S_{XY}-S_{YX})(S_{XX}+S_{YY})^*\rangle &
\langle j(S_{XY}-S_{YX})(S_{XX}-S_{YY})^*\rangle &
\end{matrix}\right.\\
& \left.\begin{matrix}
& \langle(S_{XX}+S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}+S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle(S_{XX}-S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}-S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle|S_{XY}+S_{YX}|^2\rangle
& \langle-j(S_{XY}+S_{YX})(S_{XY}-S_{YX})^*\rangle\\
& \langle j(S_{XY}-S_{YX})(S_{XY}+S_{YX})^*\rangle
& \langle|S_{XY}-S_{YX}|^2\rangle
\end{matrix}\right]
\end{aligned}
\end{align}
\end{document}
It's perfect when used in LaTeX and gives the following pdf result:
but unfortunately when I try to copy and paste the code between \begin{document} and \end{document} in MathType to create the same expression in word, I get the result:
It seems that MathType doesn't parse the codes \begin{aligned}[t] and \end{aligned} and as you know these are just amsmath packages code.
Do you know of any way -modifying the code or mathtype settings- to solve this problem?
Or do you have another suggestion to embed Latex equation into MS Word 2010?
Here is a toned-down version of your construction that doesn't use aligned:
\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage{amsmath}
\begin{document}
\begin{align}
T_4 &= \langle \underline{k}\,.\,\underline{k}^{*^T} \rangle=
\left\langle
\begin{bmatrix}
|k_1|^2 & k_1k_2^* & k_1k_3^* & k_1k_4^* \\
k_2k_1^* & |k_2|^2 & k_2k_3^* & k_2k_4^* \\
k_3k_1^* & k_3k_2^* & |k_3|^2 & k_3k_4^* \\
k_4k_1^* & k_4k_2^* & k_4k_3^* & |k_4|^2
\end{bmatrix}
\right\rangle \\
&= \frac{1}{2}
\left[\begin{matrix}
\langle|S_{XX}+S_{YY}|^2\rangle &
\langle(S_{XX}+S_{YY})(S_{XX}-S_{YY})^*\rangle &\\
\langle(S_{XX}-S_{YY})(S_{XX}+S_{YY})^*\rangle &
\langle|S_{XX}-S_{YY}|^2\rangle & \cdots\cdots\\
\langle(S_{XY}+S_{YX})(S_{XX}+S_{YY})^*\rangle&
\langle(S_{XY}+S_{YX})(S_{XX}-S_{YY})^*\rangle & \cdots\cdots\\
\langle j(S_{XY}-S_{YX})(S_{XX}+S_{YY})^*\rangle &
\langle j(S_{XY}-S_{YX})(S_{XX}-S_{YY})^*\rangle &
\end{matrix}\right. \nonumber \\
& \phantom{{}= \frac{1}{2}}
\left.\begin{matrix}
& \langle(S_{XX}+S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}+S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle(S_{XX}-S_{YY})(S_{XY}+S_{YX})^*\rangle
& \langle -j(S_{XX}-S_{YY})(S_{XY}-S_{YX})^*\rangle\\
\cdots\cdots& \langle|S_{XY}+S_{YX}|^2\rangle
& \langle-j(S_{XY}+S_{YX})(S_{XY}-S_{YX})^*\rangle\\
& \langle j(S_{XY}-S_{YX})(S_{XY}+S_{YX})^*\rangle
& \langle|S_{XY}-S_{YX}|^2\rangle
\end{matrix}\right]
\end{align}
\end{document}
It's not possible to test this without access to MathType. So, while the above doesn't use aligned, you may have to remove some commands that are unknown to MathType.

Write string as it is to a file in Matlab

In a matlab script, I'm generating a latex table. A part of that table for example looks likes this.
\multirow{2}{*}{\textbf{b1}}
&
2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\
& 4 & 2 & 20184 & 10763 & 74508 & 1830 & 1970 & 2029 & 8\% & 11\% \\
This string is saved in variable str. Now when I try to write str to a file by using the following code.
f = fopen( 'report\results.tex', 'w' );
fprintf( f, str );
fclose(f);
I get the following warning.
Warning: Invalid escape sequence appears in format string.
See help sprintf for valid escape sequences.
That is probably due to many backslash characters in my string, which is used as escape sequence. Now how can I print this string to a file as it is.
escape the backslashes and percent signs:
str = strrep(str,'\','\\');
str = strrep(str,'%','%%');
If it's just text your printing, this'll be fine.
Minimal working example:
str = '2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\'
str = strrep(str,'\','\\');
str = strrep(str,'%','%%');
f=fopen('testing123.txt','w');
fprintf(f,str);
fclose(f);
and the file reads:
2 & 3 & 10092 & 10763 & 103390 & 2797 & 2929 & 3008 & 5\% & 8\% \\
OR as Ben A. suggests, use fwrite:
fwrite(f,str)
and I think
fprintf(f,'%s',str)
will also do the trick, and it's best to also include a newline:
fprintf(f,'%s\n',str)

WMI command to connect to remote machines and retrieve Software Version and Installation Date

I need help in connecting to 2 remote machines running Windows XP and retrive details of a software version and installation date.
I am new to WMI and would appreciate if someone could guide me in the right direction.
At the moment , I execute the below command manually on the machines.
wmic product where "Vendor like '%xyz%'" get Name, Version
I will give you a much simple version written in PowerShell.
Get-WmiObject -Class Win32_Product | Select Version,InstallDate | Export-Csv -Path C:\Scripts\Software.csv
Simple!
in order to list the installed software in a local or remote machine using the WMI you must use the Win32_Product wmi class.
check this vbscript sample
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.tsv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
if you need use this wmi class from another language like C#, Vb Net or Delphi you can use a tool like the WMI Code Creator or WMI Delphi Code Creator to help you to build the WQL sentence.