text word2tex

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text word2tex相关的知识,希望对你有一定的参考价值。

Sub word2tex(ByVal control As IRibbonControl)
With ActiveDocument.Content.Find
  .Text = "^p"
  .Font.Bold = 1
  .MatchWildcards = False
  .Replacement.Text = "^p"
  .Replacement.Font.Bold = 0
  .Replacement.Font.Italic = 0
  .Execute Replace:=wdReplaceAll
End With

Call formatSelect("italic", "\emph{")

Call formatSelect("bold", "\textbf{")

Call formatSelect("superscript", "\textsuperscript{")



Call formatSelect("subscript", "\textsubscript{")


 
End Sub
Sub formatSelect(str As String, str1 As String)
Dim seclen As Integer
    Selection.HomeKey wdStory

    With Selection.Find
    .ClearFormatting
    .Text = ""
    .Wrap = wdFindStop
    .MatchWildcards = False
    
    Select Case str
    
    Case "bold"
    .Font.Bold = -1
    
    Case "italic"
    .Font.Italic = -1
    
    Case "subscript"
    .Font.Subscript = -1
    
    Case "superscript"
    .Font.Superscript = -1
    
    End Select
    
    .Replacement.Text = ""
    
    Do
    .Execute
    If Not .Found Then
    Exit Do
    Else
    
      If Asc(Selection.Text) = 13 Then
        seclen = Len(Selection.Range.Text) + Len(str1) + 2
        Selection.Range.Text = str1 + "\textsubscript{" + Selection.Range.Text + "}"
        Selection.MoveRight wdCharacter, seclen
      Else
        seclen = Len(Selection.Range.Text) + Len(str1) + 1
        Selection.Range.Text = str1 + Selection.Range.Text + "}"
        Selection.MoveRight wdCharacter, seclen
      End If
   
    End If
    Loop
  End With
  
End Sub

以上是关于text word2tex的主要内容,如果未能解决你的问题,请参考以下文章

如何把Word格式的文本转换成tex各式的???

如何 把word文件转成Latex文件,并打开Latex文件

安装MathType后在Word中复制全文时,公式部分如何自动替换为MathML LaTeX 的代码?

库魔法。 text/plain 而不是 text/javascript text/css

<!-- text --> 和 /* text */ 注释有啥区别?

VB中 如何复制Text1.text的字体到剪贴板? 如何剪切?