Como criar uma matriz aumentada no editor de palavras do Word 2007+?

2

Como criar uma matriz aumentada no editor de equações do Word 2007+ (2010)?

É possível?

    
por AlexP11223 02.11.2013 / 18:56

3 respostas

2

Eu acho que você pode fazer assim ...

  1. Insira uma equação.
  2. No menu suspenso de Colchete, insira o primeiro item do "Colchete com separadores "group
  3. Selecione a primeira das duas caixas
  4. No menu suspenso Matriz, insira uma matriz vazia 3x3
  5. Clique com o botão direito do mouse na matriz e use a opção Inserir para inserir colunas e linhas conforme necessário
  6. Selecione a segunda das duas caixas originais
  7. No menu suspenso Matriz, insira uma matriz vazia 3x1 e adicione linhas conforme necessário.

Isso resulta em um separador bastante próximo das duas matrizes. Para adicionar espaço extra, após o passo (4) você pode digitar um espaço, e antes do passo 6, você pode inserir um espaço. Eu não sei se isso é uma boa maneira de fazer as coisas.

Você pode fazer isso em VBA usando algo assim. Este material é tudo novo para mim, assim pode, sem dúvida, ser melhorado. Se você estiver trabalhando apenas regularmente com um pequeno número de tamanhos de matriz, considere usar o VBA para gerar cada matriz e, em seguida, salve-a como um bloco de construção / autotexto.

Sub testInsertAugmentedMatrix1()
' Insert a test equation at the selection point
Call insertAugmentedMatrix1(Selection.Range, 2, 5)
End Sub

Sub insertAugmentedMatrix1(rng As Word.Range, RowCount As Integer, ColumnCount As Integer)
' Insert a "basic" augmented matrix at the specified range,
' with RowCount rows, ColumnCount columns, and a single column after the separator

Dim mainFunction As Word.OMathFunction
Dim subFunction As Word.OMathFunction
' Insert the framework
rng.OMaths.Add rng
With rng.OMaths(1)
  Set mainFunction = .Functions.Add(.Range, wdOMathFunctionDelim, 2)
  With mainFunction
    .Delim.BegChar = 40
    .Delim.SepChar = 124
    .Delim.EndChar = 41
    .Delim.Grow = True
    .Delim.Shape = wdOMathShapeCentered
  End With
  With mainFunction.Args(1)
    Set subFunction = .Functions.Add(.Range, wdOMathFunctionMat, ColumnCount * RowCount, ColumnCount)
    subFunction.Range.InsertAfter " "
  End With
  With mainFunction.Args(2)
    Set subFunction = .Functions.Add(.Range, wdOMathFunctionMat, RowCount, 1)
    subFunction.Range.InsertBefore " "
  End With
  Set subFunction = Nothing
  Set mathFunction = Nothing
End With
End Sub

Outra maneira no VBA é criar uma "string matemática" assim:

Sub testInsertAugmentedMatrix2()
' Insert a test equation at the selection point
Call insertAugmentedMatrix2(Selection.Range, 4, 6)
End Sub

Sub insertAugmentedMatrix2(rng As Word.Range, RowCount As Integer, ColumnCount As Integer)
Const mthMatrix As Long = &H25A0 '"Black Square"
Const chrMatrixColumnDelimiter As String = "&"
Const chrMatrixRowDelimiter As String = "@"
Const mthVbar As Long = &H2502

Dim i As Integer
Dim strArray As String
strArray = ""
For i = 1 To RowCount
  If i > 1 Then
    strArray = strArray & chrMatrixRowDelimiter
  End If
  strArray = strArray & String(ColumnCount - 1, chrMatrixColumnDelimiter)
Next
rng.Text = "(" & _
ChrW(mthMatrix) & "(" & strArray & ")" & _
" " & ChrW(mthVbar) & " " & _
ChrW(mthMatrix) & "(" & String(RowCount - 1, chrMatrixRowDelimiter) & ")" & _
")"
rng.OMaths.Add rng
rng.OMaths.BuildUp

End Sub

Ou, você pode usar os tokens \ matrix \ autocorrect \ math \ etc, em vez dos caracteres especiais Unicode, como este. A função mathSubstitute é copiada de meu post aqui e não foi extensivamente testado. Acho que esta é potencialmente a abordagem mais legível.

Sub testInsertAugmentedMatrix3()
' Insert a test equation at the selection point
Call insertAugmentedMatrix3(Selection.Range, 4, 6)
End Sub

Sub insertAugmentedMatrix3(rng As Word.Range, RowCount As Integer, ColumnCount As Integer)
Const mthMatrix As String = "\matrix"
Const chrMatrixColumnDelimiter As String = "&"
Const chrMatrixRowDelimiter As String = "@"
Const mthVbar As String = "\vbar"

Dim i As Integer
Dim strArray As String
strArray = ""
For i = 1 To RowCount
  If i > 1 Then
    strArray = strArray & chrMatrixRowDelimiter
  End If
  strArray = strArray & String(ColumnCount - 1, chrMatrixColumnDelimiter)
Next
rng.Text = mathSubstitute("(" & _
mthMatrix & "(" & strArray & ")" & _
" " & mthVbar & " " & _
mthMatrix & "(" & String(RowCount - 1, chrMatrixRowDelimiter) & ")" & _
")")
rng.OMaths.Add rng
rng.OMaths.BuildUp

End Sub

Function mathSubstitute(s As String) As String
Const bslash As String = "\"
Dim a() As String
Dim sout As String
Dim i As Integer
Dim j As Integer
Dim sac As String
sout = ""
If s <> "" Then
  a = Split(s, bslash)
  sout = a(LBound(a))
  For i = LBound(a) + 1 To UBound(a)
    Debug.Print a(i)
    For j = 1 To Len(a(i))
      On Error Resume Next
      sac = Application.OMathAutoCorrect.Entries(bslash & Left(a(i), j)).Value
      If Err.Number = 0 Then
        sout = sout & sac & Mid(a(i), j + 1)
        Exit For
      Else
        sac = ""
        Err.Clear
      End If
    Next
    If sac = "" Then sout = sout & bslash & a(i)
    'Debug.Print sout
  Next
End If
On Error GoTo 0
mathSubstitute = sout
End Function

Existe um artigo de Murray Sargent aqui que descreve como tudo isso é deveria funcionar. Eu não acho que a coisa de numeração de equações lá dentro funcione no Word , mas isso pode acontecer em outro lugar.

    
por 03.11.2013 / 14:13
2

Crie um objeto de equação. Clique com o botão direito, mude para inline. Cole o seguinte, clique com o botão direito e mude para exibir.

[■ (& @ &) │ ■ (& @ &)]

Isso lhe dará uma matriz aumentada com duas partes 2x2 separadas por um divisor. Em geral, a mudança para inline dá a você a chance de mexer com o código que gera o objeto de equação.

    
por 24.04.2014 / 02:22
0

Isso funcionou para mim no Word e no OneNote.

Digite [|] e um espaço no editor de equações. Agora você terá dois espaços reservados adjacentes ao | onde você pode inserir duas matrizes sem colchetes (na barra de ferramentas). Depois de inserir as duas matrizes, você pode inserir espaços antes e depois do | para torná-lo mais legível.

    
por 24.02.2016 / 21:14