A couple of n00b questions

Deplate
2007-11-27
2013-04-17
  • Hunter Kelly

    Hunter Kelly - 2007-11-27

    Hi there, I'm new to both deplate and LaTex, and I have a few questions:

    1)  How can I use Unicode escape chars, and get them to show up properly in the generated latex file (and then pdf)?  I know I'll probably need to do something to tell latex it should be utf-8 encoding, but I also don't know what the escape chars would be.  I tried just putting &#772 but that just got put verbatim in the text.

    2)  How can I generate a TOC?  I have the tex file, but I don't know how to get it to include a TOC.  I've been using TeXShop on the Mac to create the pdf file (haven't had the time to figure out how to do in from the command line yet).   Ideally, I'd like a TOC with page numbers, etc, at the front of the document.  Currently all the text is in a single file, but will be eventually be split up into multiple files.   I was able to sorta fake a TOC by using deplate -i deplate-headings, but that didn't give page numbers, so it's not really an ideal solution.

    3)  Just out of curiosity, is there any way to do bold?  I know how to do __emphasis__, but I didn't see anything for bold.

    Thanks a million, deplate is a great tool!

     
    • Tom Link

      Tom Link - 2007-11-27

      > 1) How can I use Unicode escape chars

      Couldn't you just type the letters the way they are? There should be no
      need to escape anything in the source document that is fed to deplate.
      You should be able to write your document in utf8 encoding and
      everything else should be done automactically. You'll probably have to
      tell deplate about the encoding though:

          #VAR: encoding=utf-8

      If this doesn't work, could you mail me a sample document?

      > &#772

      Which character should this be? COMBINING MACRON?

      > 2) How can I generate a TOC?

      In the viki/deplate document, insert

          #LIST: toc

      See http://deplate.sourceforge.net/Commands.html#listIndex

      You have to run latex at least twice.

      > 3) Just out of curiosity, is there any way to do bold? I know how to do
      > __emphasis__, but I didn't see anything for bold.

      There is no bold per se. Bold is physical/visual markup, but markup
      should work at a semantic level (emphasize). Although some markup
      languages support something like "strong emphasis", many consider this
      bad style. One style for emphasizing text should be sufficient.

      If you want to make the latex formatter display emphasized text as bold,
      you have about the following options:

      #1
      Override Deplate::Formatter::LaTeX#format_emphasize.

      E.g. in ~/.deplate/config.rb, you could write

      class Deplate::Formatter::LaTeX
          def format_emphasize(invoker, text=nil)
              text ||= invoker.elt || invoker.text
              "\\textbf{%s}" % text
          end
      end

      #2
      Use some LaTeX-only solution -- you'd have to search the web.

      If you want emphasize and bold, you could do something like

          Foo {text style=bold: important} bar.

      And then define a bold style in deplate.sty (for LaTeX output) or the
      CSS file (for HTML output).

      If you want some markup for this, you could use #DefParticle[1] or
      define your own particle class (based on some Deplate::Input::Wiki::Bold
      as defined in deplate/wiki-markup.rb).

      HTH,
      Thomas.

      [1] http://deplate.sourceforge.net/Regions.html#hd0010003002

       
      • Hunter Kelly

        Hunter Kelly - 2007-11-27

        This may sound stupid, but I actually don't know how to type these chars!  These unicode escapes are basically for Chinese pinyin, and getting the 4 tones over the appropriate vowel in the words.  I was hoping to writing a macro to help this out for me.

        Maybe an example would help:

        Yin has the first tone, and Yang has the second tone.  So I was going to be writing this (with the help of a macro) as
        (something like) Yi#772n and Ya#769ng - depending on what the actual escape sequence is, of course.

        I'm using the unicode chars found on http://www.pinyin.info/unicode/testpage.html, I don't know the exact names or whatever of the exact characters themselves.

        Thanks for the help!

        I also found the excellent makefile module, which makes things really handy!  I'm really impressed with deplate as a whole, I must say...

         
    • Hunter Kelly

      Hunter Kelly - 2007-11-28

      Here's a sample document of what I'm trying to do.  I'm just using a makefile that I generated with:

      deplate -i deplate  -m makefile -x -m latex-emph-table-head -f latex --pdf test.txt

      The generated TeX file looks pretty reasonable, if I cat it, the characters look correct, but when the generated PDF doesn't look right - the I don't get the accent chars. 

      This may just be a LaTeX thing, but I don't really know diddly about LaTeX, so...

      ---->8------
      #VAR: encoding=utf-8
      #Ruby context=ruby <<--
      #$KCODE='UTF8'
      #require 'jcode'
      class Deplate::Macro::PinYin < Deplate::Macro
          register_as 'py'
          TONES = [772, 769, 780, 768]
          def setup(text)
              text =~ /(\w+?)\s*([1-4])/
              word = $1
              tone = $2.to_i
              puts "text: '#{text}' word: #{word} tone: #{tone}"
              if word.index(/a/i)
                pos = word.index(/a/i)
              elsif word.index(/e/i)  
                pos = word.index(/e/i)
              elsif word.index("ou")  
                pos = word.index("ou")
              else
                pos = word.rindex(/[iou]/i)
              end
              puts "POS: #{pos}"
              pos += 1
              pinyin = word.insert(pos, [TONES[tone-1]].pack("U*"))
              puts "PINYIN: #{pinyin}"
              @elt = @deplate.parse(@container, pinyin)
          end
      end
      --

      {py: Yin 1} & {py: Yang3}
      {py: Qi 4}

       
      • Tom Link

        Tom Link - 2007-11-28

        In the CVS there is a entities-UTF8 module that enables named entities
        and numbered characters. The characters are replaced with the
        corresponding UTF8 codes.

        http://deplate.cvs.sourceforge.net/deplate/deplate/lib/deplate/mod/entities-utf8.rb?revision=1.1&view=markup

        The bad new is that I have no idea how to get this to work with latex. I
        assume the problems are about the same as yours.

        I personally don't know Chinese. A Google search brought this up:
        http://www.ctan.org/tex-archive/languages/japanese/CJK/4_7.0/doc/pinyin.txt

        I assume there are some packages around that can be used to insert these
        characters with some macros. I can remember that somebody speaking
        Chinese once wrote that utf8 is the preferred solution for html output
        but some special encoding for latex output. I'd suggest to find a viable
        latex solution first (with this I don't think I can be of much help) and
        then, building on this solution, a way to make deplate format the input properly.

         
    • Hunter Kelly

      Hunter Kelly - 2007-11-30

      So, that pinyin style you found works perfectly, and fortunately, was already included in my LaTeX distro.

      So, now I just need to figure out how to get something like \Qi3 to get passed to the LaTeX system without being escaped by deplate first, and how to get the appropriate \usepackage{pinyin} inserted up at the top of the file.  I'll dig around some more, but any help would be appreciated.

      Thanks for your help

       
      • Tom Link

        Tom Link - 2007-11-30

        Abbreviations would probably be the easiest ad-hoc solution:
        http://deplate.sourceforge.net/Commands.html#hd0011004

        There is an example on that page for how to define a sigma symbol which
        should be easily adapted to this particular problem.

         
    • Hunter Kelly

      Hunter Kelly - 2007-11-30

      I've got this sorted - a DefMacroN and  the hook_pre_prepare_my_configuration allowed me to do what I need.

      Thanks again!

       
    • Hunter Kelly

      Hunter Kelly - 2007-11-30

      I just wanted to say thanks again for a wonderful tool - I was able to use ABBREV with regex's to work out a solution that works for both latex and html, without having to change anything and without littering my document with lots of ugly macros.

      Deplate for the win!

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks