improper matrix print out latex - matrix

using Latex to print out a Matrix , I noticed I can not place the numbers under each other correctly
here is the code, I really appreciate your help
\begin{center}
$ABD=
\begin{bmatrix}
12610207.7\quad 5695754.3\quad 0\quad 0\quad 0\quad 0 \\
5695754.3\quad 10737818.8\quad 0\quad 0\quad 0\quad 0 \\
0\quad 0\quad 2800468.2\quad 0\quad 0\quad 0\\
0\quad 0\quad 0\quad 37.3\quad 125.08\quad 0.12\\
0\quad 0\quad 0\quad 125.08\quad 0.24\quad 0\\
0\quad 0\quad 0\quad 0\quad 0\quad 0.12
\end{bmatrix}
\end{center}
$
\begin{equation} \label{10}
\end{equation}
\end{center}

Matrix (and other tabular or array) constructions use & to denote the column delineation, not \quad:
\documentclass{article}
\usepackage{amsmath,siunitx}
\begin{document}
Using \verb|bmatrix|:
\[
ABD =
\begin{bmatrix}
12610207.7 & 5695754.3 & 0 & 0 & 0 & 0 \\
5695754.3 & 10737818.8 & 0 & 0 & 0 & 0 \\
0 & 0 & 2800468.2 & 0 & 0 & 0 \\
0 & 0 & 0 & 37.3 & 125.08 & 0.12 \\
0 & 0 & 0 & 125.08 & 0.24 & 0 \\
0 & 0 & 0 & 0 & 0 & 0.12
\end{bmatrix}
\]
Using \verb|array|:
\[
ABD =
\left[\begin{array}{#{}
S[table-format=9.1]
S[table-format=9.1]
S[table-format=7.1]
S[table-format=3.2]
S[table-format=3.2]
S[table-format=1.2]#{}}
12610207.7 & 5695754.3 & 0 & 0 & 0 & 0 \\
5695754.3 & 10737818.8 & 0 & 0 & 0 & 0 \\
0 & 0 & 2800468.2 & 0 & 0 & 0 \\
0 & 0 & 0 & 37.3 & 125.08 & 0.12 \\
0 & 0 & 0 & 125.08 & 0.24 & 0 \\
0 & 0 & 0 & 0 & 0 & 0.12
\end{array}\right]
\]
With bmatrix you don't have to specify the number of columns. However, there is a limit, but this can be extended.
siunitx was added to align the columns inside the array in a specific table-format way. Using a column specification #{}*{6}{c}#{} would have worked to produce a similar output as bmatrix.

Related

How to position LaTeX table in Overleaf

I have a correlation matrix output in R, when I paste it Overleaf the table is too far
to the right and some values are missing. I have the same issue with other tables as
well, how can I fix this? The code for this matrix is the following
\begin{table}[ht]
\centering
\begin{tabular}{rllllllllllllll}
\hline
& avsumarwinsorized & FE & dispstd & winsorizedNetOptLM & roa & roastd & RETURN & MV & beta & BTM & lognoa & winsmin & winsmax & winsmean \\
\hline
avsumarwinsorized & 1.000 & -0.017* & -0.018* & 0.068*** & -0.005 & -0.011 & 0.002 & -0.014 & -0.017* & -0.008 & -0.010 & 0.019* & 0.003 & 0.019* \\
FE & -0.026*** & 1.000 & 0.582*** & -0.205*** & -0.298*** & 0.290*** & -0.205*** & -0.351*** & 0.186*** & 0.358*** & -0.243*** & -0.089*** & -0.050*** & -0.091*** \\
dispstd & -0.025** & 0.557*** & 1.000 & -0.282*** & -0.444*** & 0.314*** & -0.338*** & -0.347*** & 0.230*** & 0.466*** & -0.153*** & -0.104*** & -0.057*** & -0.100*** \\
winsorizedNetOptLM & 0.073*** & -0.067*** & -0.050*** & 1.000 & 0.285*** & -0.090*** & 0.246*** & 0.072*** & -0.021** & -0.251*** & 0.032*** & 0.046*** & -0.092*** & 0.005 \\
roa & -0.017* & -0.068*** & -0.056*** & 0.160*** & 1.000 & -0.023** & 0.284*** & 0.284*** & -0.145*** & -0.522*** & 0.177*** & 0.064*** & 0.022** & 0.053*** \\
roastd & 0.003 & 0.048*** & 0.034*** & -0.074*** & -0.359*** & 1.000 & -0.092*** & -0.263*** & 0.098*** & -0.064*** & -0.102*** & -0.103*** & -0.075*** & -0.118*** \\
RETURN & -0.007 & -0.062*** & -0.049*** & 0.143*** & 0.156*** & -0.007 & 1.000 & 0.185*** & 0.065*** & -0.365*** & 0.029*** & 0.024** & 0.027*** & 0.018* \\
MV & -0.014 & -0.020** & -0.015* & 0.003 & 0.077*** & -0.055*** & 0.001 & 1.000 & -0.207*** & -0.346*** & 0.672*** & 0.067*** & 0.177*** & 0.117*** \\
beta & -0.019* & 0.068*** & 0.038*** & -0.045*** & -0.054*** & 0.055*** & 0.131*** & -0.121*** & 1.000 & 0.150*** & -0.096*** & -0.036*** & -0.040*** & -0.042*** \\
BTM & -0.015 & -0.075*** & -0.015 & -0.128*** & -0.107*** & 0.024** & -0.134*** & -0.056*** & 0.081*** & 1.000 & -0.238*** & -0.100*** & -0.061*** & -0.088*** \\
lognoa & -0.013 & -0.063*** & -0.028*** & 0.052*** & 0.096*** & -0.076*** & -0.023** & 0.313*** & -0.093*** & -0.091*** & 1.000 & 0.048*** & 0.152*** & 0.093*** \\
winsmin & 0.009 & -0.035*** & -0.023** & 0.038*** & 0.036*** & -0.048*** & 0.006 & -0.012 & -0.038*** & -0.056*** & 0.060*** & 1.000 & 0.357*** & 0.925*** \\
winsmax & 0.001 & -0.031*** & -0.011 & -0.087*** & 0.028*** & -0.016* & -0.001 & 0.081*** & -0.052*** & -0.018* & 0.152*** & 0.288*** & 1.000 & 0.550*** \\
winsmean & 0.010 & -0.036*** & -0.024** & 0.008 & 0.044*** & -0.056*** & -0.005 & 0.028*** & -0.049*** & -0.052*** & 0.104*** & 0.889*** & 0.513*** & 1.000 \\
\hline
\end{tabular}
\end{table}
Screenshot of the table in Overleaf
No way a table this large will reasonable fit onto a page. Even with
abbreviating some of the verrrrrrrrry long variable names
reducing the margins of the paper
using a landscape paper
it will still need an unreadable small size to fit on the page:
\documentclass{article}
\usepackage[landscape,hmargin=1cm]{geometry}
\begin{document}
\begin{table}[ht]
\centering
\tiny
\begin{tabular}{rllllllllllllll}
\hline
& avs. & FE & dispstd & win. & roa & roastd & RETURN & MV & beta & BTM & lognoa & winsmin & winsmax & winsmean \\
\hline
avs. & 1.000 & -0.017* & -0.018* & 0.068*** & -0.005 & -0.011 & 0.002 & -0.014 & -0.017* & -0.008 & -0.010 & 0.019* & 0.003 & 0.019* \\
FE & -0.026*** & 1.000 & 0.582*** & -0.205*** & -0.298*** & 0.290*** & -0.205*** & -0.351*** & 0.186*** & 0.358*** & -0.243*** & -0.089*** & -0.050*** & -0.091*** \\
dispstd & -0.025** & 0.557*** & 1.000 & -0.282*** & -0.444*** & 0.314*** & -0.338*** & -0.347*** & 0.230*** & 0.466*** & -0.153*** & -0.104*** & -0.057*** & -0.100*** \\
win. & 0.073*** & -0.067*** & -0.050*** & 1.000 & 0.285*** & -0.090*** & 0.246*** & 0.072*** & -0.021** & -0.251*** & 0.032*** & 0.046*** & -0.092*** & 0.005 \\
roa & -0.017* & -0.068*** & -0.056*** & 0.160*** & 1.000 & -0.023** & 0.284*** & 0.284*** & -0.145*** & -0.522*** & 0.177*** & 0.064*** & 0.022** & 0.053*** \\
roastd & 0.003 & 0.048*** & 0.034*** & -0.074*** & -0.359*** & 1.000 & -0.092*** & -0.263*** & 0.098*** & -0.064*** & -0.102*** & -0.103*** & -0.075*** & -0.118*** \\
RETURN & -0.007 & -0.062*** & -0.049*** & 0.143*** & 0.156*** & -0.007 & 1.000 & 0.185*** & 0.065*** & -0.365*** & 0.029*** & 0.024** & 0.027*** & 0.018* \\
MV & -0.014 & -0.020** & -0.015* & 0.003 & 0.077*** & -0.055*** & 0.001 & 1.000 & -0.207*** & -0.346*** & 0.672*** & 0.067*** & 0.177*** & 0.117*** \\
beta & -0.019* & 0.068*** & 0.038*** & -0.045*** & -0.054*** & 0.055*** & 0.131*** & -0.121*** & 1.000 & 0.150*** & -0.096*** & -0.036*** & -0.040*** & -0.042*** \\
BTM & -0.015 & -0.075*** & -0.015 & -0.128*** & -0.107*** & 0.024** & -0.134*** & -0.056*** & 0.081*** & 1.000 & -0.238*** & -0.100*** & -0.061*** & -0.088*** \\
lognoa & -0.013 & -0.063*** & -0.028*** & 0.052*** & 0.096*** & -0.076*** & -0.023** & 0.313*** & -0.093*** & -0.091*** & 1.000 & 0.048*** & 0.152*** & 0.093*** \\
winsmin & 0.009 & -0.035*** & -0.023** & 0.038*** & 0.036*** & -0.048*** & 0.006 & -0.012 & -0.038*** & -0.056*** & 0.060*** & 1.000 & 0.357*** & 0.925*** \\
winsmax & 0.001 & -0.031*** & -0.011 & -0.087*** & 0.028*** & -0.016* & -0.001 & 0.081*** & -0.052*** & -0.018* & 0.152*** & 0.288*** & 1.000 & 0.550*** \\
winsmean & 0.010 & -0.036*** & -0.024** & 0.008 & 0.044*** & -0.056*** & -0.005 & 0.028*** & -0.049*** & -0.052*** & 0.104*** & 0.889*** & 0.513*** & 1.000 \\
\hline
\end{tabular}
\end{table}
\end{document}
There is two ways for such a large table
Change the format to landscape
User scalebox to reduce the size (everything will be small, doesn't worth as a solution)

Enlarge row-height dynamically with pictures size

I am building a table in LaTeX that contains a column of pictures. I would like the size of the rows related to those pictures to increase their height such that the picture stays inside its cell. I tried the \\[2cm] solution, but then the text in the cells of the same rows is not centered anymore. An example to be clearer:
\documentclass[]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]
\begin{tabular}{c|c|c|c|c c c|c c c}
\multirow{ 2}{*}{} & \multirow{ 2}{*}{\textbf{mesh}} & \multirow{ 2}{*}{\textbf{dofs}} & \multirow{ 2}{*}{\textbf{levels}} & \multicolumn{3}{|c|}{\textbf{iterations}} & \multicolumn{3}{|c}{\textbf{Conv Rate}} \\ \cline{5-10}
& & & & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG} & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG}\\\hline
\multirow{ 2}{*}{\textbf{1D}} & \multirow{ 2}{*}{\includegraphics[scale = .2]{path1}& \multirow{ 2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
\multirow{8}{*}{\textbf{2D}} & \multirow{ 2}{*}{\includegraphics[scale = .1]{path2}& \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\[2cm] \cline{2-10}
& \multirow{ 2}{*}{mesh22} & \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
&\multirow{ 2}{*}{mesh23} & \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
& \multirow{ 2}{*}{mesh24}& \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
\end{tabular}
\end{table}
\end{document}
Different approach: instead of merging the cell with your image, you could make the other cells have multiple lines
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]
\begin{tabularx}{\linewidth}{c|m{2cm}|Y|Y|YYY|YYY}
\hline
\multirow{9}{*}{2D} & \includegraphics[scale=.2,valign=t]{example-image-duck} & 100k & 2 \linebreak 5 & -\linebreak -&-\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - \\
\cline{2-10}
& \includegraphics[width=1cm,height=3cm,valign=t]{example-image-duck} & 100k & 2 \linebreak 5 & -\linebreak -&-\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - \\
\hline
\end{tabularx}
\end{table}
\end{document}
... or if you prefer vertically centred cells:
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{multirow}
\def\tabularxcolumn#1{m{#1}}
\begin{document}
\begin{table}[h!]
\begin{tabularx}{\linewidth}{c|m{2cm}|Y|Y|YYY|YYY}
\hline
\multirow{9}{*}{2D} & \includegraphics[scale=.2,valign=b]{example-image-duck} & 100k & 2 \linebreak 5 & -\linebreak -&-\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - \\
\cline{2-10}
& \includegraphics[width=1cm,height=3cm,valign=b]{example-image-duck} & 100k & 2 \linebreak 5 & -\linebreak -&-\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - & -\linebreak - \\
\hline
\end{tabularx}
\end{table}
\end{document}

Write Double Quotation Mark

I am trying to overwrite specific lines in a sequential file
For example if file has:
"1"
"Kii"
"Kii"
"Kii"
"Kii"
"2"
"Troy Martinez"
"Edoy"
"Edoy"
"69"
"3"
"Snoop Dogg"
"Weed"
"President Troy"
"420"
And I have this code to overwrite
Private Sub OverWrite()
Dim Count As Integer
On Error GoTo ErrSub
LineCount = 1
Open App.Path & "\Data.txt" For Input As #1
Do While Not EOF(1)
If LineCount < ((IDCount - 1) * 5) + 1 Or LineCount >= (IDCount * 5) + 1 Then
For Count = 0 To 4
Input #1, TextTemp
FileText = FileText & """ & Text1(Count) & """ & vbCrLf
LineCount = LineCount + 1
Next Count
Else
For Count = 0 To 4
Input #1, TextTemp
FileText = FileText & """ & TextTemp & """ & vbCrLf
LineCount = LineCount + 1
Next Count
End If
Loop
Close
Open App.Path & "\Data.txt" For Output As #1
Print #1, FileText
Close
ErrSub:
Resume Next
End Sub
Assuming my IDCount is 2, the text file becomes
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
" & TextTemp & "
" & TextTemp & "
" & TextTemp & "
" & TextTemp & "
" & TextTemp & "
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
" & Text1(Count) & "
How do I fix this? Thanks
I am very noob
Edit: My Option Explicit Is
Option Explicit
Dim IDCount As Integer
Dim LineCount As Integer
Dim FileText As String
Dim TextTemp
4 quotes ("""") escape a single quote (") so:
FileText = FileText & """" & Text1(Count) & """" & vbCrLf
(chr$(34) also outputs a ")

IP calculator. Decimal to binary

I have ploblem with converting decimal numbers to binary. I want to have space between 8b, but i dont know how to do that in the code.
Function str2bin(strAddress)
'special decimal to binary function
'input 4 octet ip address
'output 32bit binary number
objAddress = Split(strAddress, ".")
For Each strOctet In objAddress
intOctet = CInt (strOctet)
strOctBin = ""
For x = 1 To 8
If intOctet Mod 2 > 0 Then
strOctBin = "1" & strOctBin
Else
strOctBin = "0" & strOctBin
End If
intOctet = Int(intOctet / 2)
Next
str2bin = str2bin & strOctBin
Next
End Function
'-----------------------------------------------------------
Quick and very dirty:
Append a space after each octet:
str2bin = str2bin & strOctBin & " "
and Trim() the return value in the calling code to get rid of the trailing space.
Evidence:
type 28139908.vbs & cscript 28139908.vbs
Option Explicit
Function str2bin(strAddress)
'special decimal to binary function
'input 4 octet ip address
'output 32bit binary number
Dim objAddress, strOctet, intOctet, strOctBin, x
objAddress = Split(strAddress, ".")
For Each strOctet In objAddress
intOctet = CInt (strOctet)
strOctBin = ""
For x = 1 To 8
If intOctet Mod 2 > 0 Then
strOctBin = "1" & strOctBin
Else
strOctBin = "0" & strOctBin
End If
intOctet = Int(intOctet / 2)
Next
str2bin = str2bin & strOctBin & " "
Next
End Function
Dim sIP : sIP = "127.15.32.255"
WScript.Echo sIP, ">" & str2bin(sIP) & "<", ">" & Trim(str2bin(sIP)) & "<"
127.15.32.255 >01111111 00001111 00100000 11111111 < >01111111 00001111 00100000 11111111<
'Subnet Calculator V1
'Script by Chavdarova
'usage cscript VBScriptSubnetCalcV2 > output.txt
'force script to run in cscript mode
Set objShell = CreateObject("WScript.Shell")
If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then
objShell.Run "%comspec% /k cscript //nologo """ & WScript.ScriptFullName & """", 1, False
WScript.Quit
End If
'a bit of test code to feed a range of addresses into script for testing
' snm="255.255.192.0"
' for iCount=0 to 255
' ip="172.16.17."&iCount
' CalcSubnet ip, snm
' next
strIP=inputbox("Vnesite IP", "Chavdarova Subnet Calc", "172.16.98.53")
strSN=inputbox("Vnesite Subnet Mask", "Chavdarova Subnet Calc", "255.255.224.0")
CalcSubnet strIP, strSN
wscript.quit
----------
function CalcSubnet(strIP,strSNM)
binSNM=str2bin(strSNM)
binIP=str2bin(strIP)
'IP <AND> SN to find Network addresses
for c=32 to 1 step -1
temp=(cint(mid(binIP,c, 1)) and cint(mid(binSNM,c, 1))) & temp
next
netwAdd=temp : temp=""
'IP <OR> SN to find blocks of all "ones" - these addresss are broadcast addresses
for c=32 to 1 step -1
temp=(cint(mid(binIP,c, 1)) or cint(mid(binSNM,c, 1))) & temp
next
bcCheck=temp : temp=""
'Calc 1st. host address in range (Network Address + 1)
ist=binAdd(netwAdd,string(31, "0")&"1")
'Calc Last host address in range (111111...1 - bcCheck + IP - 0...000001)
lst=binSub(string(32,"1"),bcCheck)
lst=binadd(lst,binIP)
lst=binsub(lst,string(31, "0")&"1" )
wscript.echo "IP "&binIP&" "&bin2str(binIP)&vbcrlf&_
"Subnet Mask "&binSNM&" "&bin2str(binSNM)&vbcrlf&_
"Subnet Network "&netwAdd&" "&bin2str(netwAdd)&vbcrlf&_
"Host min "&ist &" "& bin2str(ist) &vbcrlf&_
"Host max "&lst &" "& bin2str(lst) &vbcrlf&_
"Hosts "&binsub(lst,ist) &" "& Bin2Dec(binsub(lst,ist)) &vbcrlf
end function
----------
Function Bin2Dec(strBin)
'Plain old binary to decimal function
result = 0
for intIndex = len(strBin) to 1 step -1
strDigit = mid(strBin, intIndex, 1)
if strDigit = "0" then
'do nothing
elseif strDigit = "1" then
result = result + (2 ^ (len(strBin)-intIndex))
else
Bin2Dec = 0
exit for
end if
next
Bin2Dec = result
End Function
----------
Function bin2str(strBinary)
'special binary to decimal function
'input 32bit binary number
'output 4 octet ip address
For iPosOct = 1 To 4
strOctBin = Right(Left(strBinary, iPosOct * 8), 8)
intOctet = 0
intValue = 1
For iPosBin = 1 To Len(strOctBin)
If Left(Right(strOctBin, iPosBin), 1) = "1" Then
intOctet = intOctet + intValue
end if
intValue = intValue * 2
Next
If bin2str = Empty Then
bin2str = CStr(intOctet)
Else
bin2str = bin2str & "." & CStr(intOctet)
end if
Next
End Function
----------
Function str2bin(strAddress)
'special decimal to binary function
'input 4 octet ip address
'output 32bit binary number
objAddress = Split(strAddress, ".")
For Each strOctet In objAddress
intOctet = CInt (strOctet)
strOctBin = ""
For x = 1 To 8
If intOctet Mod 2 > 0 Then
strOctBin = "1" & strOctBin
Else
strOctBin = "0" & strOctBin
End If
intOctet = Int(intOctet / 2)
Next
str2bin = str2bin & strOctBin & " "
Next
End Function
----------
function binSub(binA,binB)
'subtract one 32bit binary number from another
'binA must be biggest
c=0
for i=32 to 1 step-1
a=cint(mid(binA,i,1))
b=cint(mid(binB,i,1))
if a=0 and b=0 and c=0 then
subt=0 : c=0
elseif a=1 and b=0 and c=0 then
subt=1 : c=0
elseif a=0 and b=1 and c=0 then
subt=1 : c=1
elseif a=1 and b=1 and c=0 then
subt=0 : c=0
elseif a=1 and b=1 and c=1 then
subt=1 : c=1
elseif a=1 and b=0 and c=1 then
subt=0 : c=0
elseif a=0 and b=1 and c=1 then
subt=0 : c=0
elseif a=0 and b=0 and c=1 then
subt=1 : c=1
else
msgbox "This function is only for subtracting 2 32bit binary numbers"
binSub=0 : exit function
end if
total=subt&total
'wscript.echo "a-"&BinA&" "&a&vbcrlf&"b-"&BinB&" "&b&vbcrlf&"subtraction "&subt&vbcrlf&"carry "&
c&vbcrlf&"x-"&total&vbcrlf&cvcrlf
next
if c=1 then
msgbox "Error you are subtracting a larger number from a smaller number"&vbcrlf&binA&vbcrlf&binB
end if
binsub=total
end function
----------
function binAdd(binA,binB)
'add two 32bit binary numbers together
c=0
for i=32 to 1 step-1
a=cint(mid(binA,i,1))
b=cint(mid(binB,i,1))
if a=0 and b=0 and c=0 then
add=0 : c=0
elseif a=1 and b=0 and c=0 then
add=1 : c=0
elseif a=0 and b=1 and c=0 then
add=1 : c=0
elseif a=1 and b=1 and c=0 then
add=0 : c=1
elseif a=1 and b=1 and c=1 then
add=1 : c=1
elseif a=1 and b=0 and c=1 then
add=0 : c=1
elseif a=0 and b=1 and c=1 then
add=0 : c=1
elseif a=0 and b=0 and c=1 then
add=1 : c=0
else
msgbox "Error this function is only for adding 2 32bit binary numbers together"
binAdd=0 : exit function
end if
total=add&total
'wscript.echo "a-"&BinA&" "&a&vbcrlf&"b-"&BinB&" "&b&vbcrlf&"addition "&add&vbcrlf&"carry "& c&vbcrlf&"x-"&total
next
binAdd=total
end function

How can I interpret this VB6 code?

I inherited a VB program that prints shipping labels. We need to update the barcode that gets printed and I'm trying to understand what the existing program is doing. There is a bunch of "WrittenData" (stored as "s") that seems to contain the Postscript code to produce the labels, but I haven't found anywhere that specifies the meaning of half this stuff.
Public Function PostScriptItem(address As Variant, Optional intPageNumberOut As Integer = 1, Optional intPageNumberIn As Integer = 2) As String
' 0 - MatchUpId
' 1 - Our Barcode
' 2 - Outgoing PostNet Code
' 3 - Outgoing Line 1
' 4 - Outgoing Line 2 (optionally EMPTY)
' 5 - Outgoing Line 3
' 6 - Outgoing Line 4
' 7 - Outgoing PlaNET Code
' 8 - Incoming PostNet Code
' 9 - Incoming Line 1
'10 - Incoming Line 2 (optionally EMPTY)
'11 - Incoming Line 3
'12 - Incoming Line 4
'13 - Incoming PlaNET Code
'14 - Title Id
'Escape Parenthesis and Backslashes
Dim tPos As Integer
For tPos = 0 To 14 Step 1
address(tPos) = Replace(address(tPos), "\", "\\")
address(tPos) = Replace(address(tPos), "(", "\(")
address(tPos) = Replace(address(tPos), ")", "\)")
Next tPos
Dim s As String
Dim pos As Integer
Dim fsize As Integer
Dim strBarcodeCaption As String
strBarcodeCaption = address(1) & " " & address(14) & " " & address(0)
pos = 50
fsize = 12
s = s & "%%Page: " & CStr(intPageNumberOut) & " " & CStr(intPageNumberOut) & vbCrLf & _
"<< /Duplex true >> setpagedevice" & vbCrLf & _
"<< /Tumble true >> setpagedevice" & vbCrLf & _
"%%BeginPageSetup" & vbCrLf & _
"180 rotate" & vbCrLf & _
"/pagelevel save def" & vbCrLf & _
"%%EndPageSetup" & vbCrLf & _
"newpath" & vbCrLf & _
"-338 -205 translate" & vbCrLf & _
"/Courier-Bold findfont 6 scalefont setfont" & vbCrLf & _
"newpath" & vbCrLf
s = s & "32 104 moveto (" & strBarcodeCaption & ") show" & vbCrLf & _
"newpath" & vbCrLf
s = s & "12 -450 translate" & vbCrLf & _
"62 104 moveto (" & strBarcodeCaption & ") show" & vbCrLf & _
"newpath" & vbCrLf & _
"30 80 moveto (^104" & address(1) & ") (height=0.3) code128 barcode" & vbCrLf & _
"newpath" & vbCrLf
s = s & "/Helvetica findfont 11 scalefont setfont" & vbCrLf & _
"0 " & CStr(pos) & " moveto (" & address(3) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
If address(4) <> Empty Then
s = s & "0 " & CStr(pos) & " moveto (" & address(4) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
End If
s = s & "0 " & CStr(pos) & " moveto (" & address(5) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
s = s & "0 " & CStr(pos) & " moveto (" & address(6) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize - 5
s = s & "1 " & CStr(pos) & " moveto (" & address(2) & ") () postnet barcode" & vbCrLf & _
"%%PageTrailer" & vbCrLf & _
"pagelevel restore" & vbCrLf & _
"showpage" & vbCrLf
s = s & "%%Page: " & CStr(intPageNumberIn) & " " & CStr(intPageNumberIn) & vbCrLf & _
"<< /Duplex true >> setpagedevice" & vbCrLf & _
"<< /Tumble true >> setpagedevice" & vbCrLf & _
"%%BeginPageSetup" & vbCrLf & _
"/pagelevel save def" & vbCrLf & _
"210 711 translate" & vbCrLf & _
"%%EndPageSetup" & vbCrLf & _
"newpath" & vbCrLf & _
"/Courier-Bold findfont 6 scalefont setfont" & vbCrLf & _
"0 21 moveto (" & address(1) & " " & address(0) & ") show" & vbCrLf & _
"gsave" & vbCrLf & _
"0.5 0.5 scale" & vbCrLf & _
"0 12 moveto (^104" & address(1) & ") (height=0.3) code128 barcode" & vbCrLf & _
"grestore" & vbCrLf & _
"newpath" & vbCrLf & _
"32 0 moveto (" & address(14) & ") show" & vbCrLf & _
"newpath" & vbCrLf & _
"/Helvetica findfont 11 scalefont setfont" & vbCrLf & _
"-70 -180 translate" & vbCrLf
pos = 56
s = s & "0 " & CStr(pos) & " moveto (" & address(9) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
If address(10) <> Empty Then
s = s & "0 " & CStr(pos) & " moveto (" & address(10) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
End If
s = s & "0 " & CStr(pos) & " moveto (" & address(11) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize
s = s & "0 " & CStr(pos) & " moveto (" & address(12) & ") show" & vbCrLf & _
"newpath" & vbCrLf
pos = pos - fsize - 5
s = s & "1 " & CStr(pos) & " moveto (" & address(8) & ") () postnet barcode" & vbCrLf & _
"%%PageTrailer" & vbCrLf & _
"pagelevel restore" & vbCrLf & _
"showpage" & vbCrLf
PostScriptItem = s
End Function
I need to change the contents of "address(2)" and "address(8)" and use a different font to print those. I tried putting the new font in the projects fonts folder and referencing it the way "postnet" and "code128" are referenced but that left me with an entirely blank label.
The "code128" font seems to get defined in a separate file called "postscript_main.ps" and I have no idea how to incorporate the new font into that, I am really lost and hoping for a clue or a link to some documentation that might get me going in the right direction.

Resources