Consulting

Results 1 to 3 of 3

Thread: LaTex it - A code to convert Word to LaTex

  1. #1

    LaTex it - A code to convert Word to LaTex

    I use VBA to convert word to LaTex using find and replace function of word.

    Sub Latex_it()
        Selection.Find.ClearFormatting
        Selection.Find.Font.Italic = True
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = ""
            .Replacement.Text = "\textit{^&}"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
           Selection.Find.ClearFormatting
        Selection.Find.Font.Bold = True
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = ""
            .Replacement.Text = "\textbf{^&}"
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    The above code adds LaTex tag to italic and bullets respectively.

    Is there a more elegant way of doing it and How to select section heading using above code and apply LateX tag

    corresponding LaTex tag for word section heading

    \section{heading level1}
    \subsection{heading level2}
    \subsubsection{heading level3}

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    The above code adds LaTex tag to italic and bullets respectively.
    Bullets or bold?

    I'd imagine that if you used styles (Heading1, Heading2, ...) a F&R for paragraphs in that style could be tagged.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Yes bold.

    Any idea how to select Heading levels.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •