diff options
| author | Ralph Amissah <ralph@amissah.com> | 2014-05-12 21:50:42 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2014-05-12 21:50:42 -0400 | 
| commit | 2b2e66c1b6c44ecb55e98ea4316b51f32c51ee80 (patch) | |
| tree | f440b7ef4768530d809cf95965058bd36de37793 /lib | |
| parent | v6: texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface (diff) | |
v6: texpdf, headings and table of contents representation
* (Closes: #744386) 1~ and 2~ result in the same formatting
  1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383
* (Closes: #744399) :A smaller formatted than :B
  A~ B~ C~ now the same size, see discussion in sisu.org under #744383
* #744383 :B and :C result in the same formatting, issue explained see sisu.org
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sisu/v6/texpdf.rb | 22 | ||||
| -rw-r--r-- | lib/sisu/v6/texpdf_format.rb | 122 | 
2 files changed, 77 insertions, 67 deletions
| diff --git a/lib/sisu/v6/texpdf.rb b/lib/sisu/v6/texpdf.rb index b3636154..5654e6df 100644 --- a/lib/sisu/v6/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -594,20 +594,26 @@ module SiSU_TeX            case dob.is            when :heading              case dob.ln -            when 1..3 -              tst.heading_major +            when 0 +              tst.title_level_A +            when 1 +              tst.section_heading_level_B +            when 2 +              tst.section_heading_level_C +            when 3 +              tst.section_heading_level_D              when 4 -              tst.level4 +              tst.heading_level_1              when 5 -              tst.level5 +              tst.heading_level_2              when 6 -              tst.level6 +              tst.heading_level_3              else dob              end            when :heading_insert              br="\n\\\\\n"              if dob.name=='book_index' -              h=tst.heading_major +              h=tst.section_heading_level_B                heading="\\clearpage\n" + h.tmp                idx_arr=[]                idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_raw(@md.opt).raw_idx @@ -628,10 +634,10 @@ module SiSU_TeX                dob.tmp={ l: l, p: p }              elsif dob.ln==2 \              and dob.obj=~/Metadata\b/ -              tst.heading_major +              tst.section_heading_level_B              elsif dob.ln==4 \              and dob.obj=~/Metadata\b/ -              h=tst.level4 +              h=tst.heading_level_1                metadata=SiSU_Metadata::TeX_Metadata.new(@md).metadata_tex                dob.tmp=h.tmp + ' ' + '\begin{scriptsize}' + metadata.join(br) + '\end{scriptsize}'              else dob.tmp='' # dob.tmp={ l: '', p: '' } diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index f7e18dc8..015a9934 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -219,95 +219,99 @@ module SiSU_TeX_Pdf        else ''        end      end -    def heading_major +    def remove_footnotes(cont_ln) +      cont_ln=if cont_ln =~/\\[Ff]ootnote/m +        cont_ln.gsub(/\s*\\[Ff]ootnote\[\d+\]\{%\s+.+?\}\s*/m,' '). +          gsub(/\s*\\[Ff]ootnote[A]\{[*+]+\d*\}\{%\S+.+?\}\s*/m,' ') +      else cont_ln +      end +    end +    def title_level_A        dob=@dob -      title=@md.title.full        dob.tmp=dob.tmp.strip if dob.tmp        dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').          gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')        cont_ln=dob.tmp.dup        cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').          gsub(@@tex_pattern_margin_number,'') -      clearp=(dob.lv =~/B/ && dob.obj =='Metadata') ? "\\clearpage\n" : '' -      if dob.tmp =~/\\[Ff]ootnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! -        cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). -          gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') -      end +      cont_ln=remove_footnotes(cont_ln) +      titleset=''        dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, -        "#{clearp}\\part*{\\1} -\\addcontentsline{toc}{section}{#{cont_ln}} -\\markboth{#{title}}\n") +        "#{titleset}\\part*{\\1} +\\markboth{#{@md.title.full}}\n")        dob      end -    def level4 -      dob=@dob +    def section_heading_level(dob)        dob.tmp=dob.tmp.strip if dob.tmp        dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').          gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')        cont_ln=dob.tmp.dup        cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). -        gsub(@@tex_pattern_margin_number,''). -        gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42 -        gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -        gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -      title=@md.title.full -      if dob.name =~/endnotes/ -        dob.tmp=dob.tmp.gsub(/.+/m,'') -      end -      if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! -        cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). -          gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') -      end -      dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,"\\subsubsection*{\\1} -\\addcontentsline{toc}{subsection}{#{cont_ln}} -\\markright{#{title}}") +        gsub(@@tex_pattern_margin_number,'') +      cont_ln=remove_footnotes(cont_ln) +      dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m, +        "\\clearpage +\\part*{\\1} +\\addcontentsline{toc}{part}{#{cont_ln}} +\\markboth{#{@md.title.full}}\n")        dob      end -    def level5 -      dob=@dob -      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 -      dob.tmp=dob.tmp.strip if dob.tmp -      dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2'). -        gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'') -      cont_ln=dob.tmp.dup -      cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2'). -        gsub(@@tex_pattern_margin_number,''). -        gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -        gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -        gsub(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa -      if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! -        cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). -          gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') +    def heading_sublevels(dob,sublev) +      if sublev==:lev1 +        sect='section' +        tocadd=%{\\addcontentsline{toc}{section}} +        pre='' +        post='' +        headadd=%{\n\\markright{#{@md.title.full}}} +      elsif sublev==:lev2 +        sect='subsection' +        tocadd=%{\\addcontentsline{toc}{subsection}} +        pre='' +        post=" \\\\\n" +        headadd='' +      elsif sublev==:lev3 +        sect='subsubsection' +        tocadd=%{\\addcontentsline{toc}{subsubsection}} +        pre='' #pre='~~~~' +        post=" \\\\\n" +        headadd=''        end -      dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, -        "\\subsubsection*{\\1} -\\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ -}") -      dob -    end -    def level6 -      dob=@dob -      # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46        dob.tmp=dob.tmp.strip if dob.tmp        dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').          gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')        cont_ln=dob.tmp.dup        cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').          gsub(@@tex_pattern_margin_number,''). +        gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42          gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22          gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 -      if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings! -        cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' '). -          gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') +      if dob.name =~/endnotes/ +        dob.tmp=dob.tmp.gsub(/.+/m,'')        end +      cont_ln=remove_footnotes(cont_ln)        dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m, -        "\\subsubsection*{\\1} -\\addcontentsline{toc}{subsubsection}{~~~~#{cont_ln} \\\\ -}") -      #dob.tmp.gsub(/^(.*)?\n?$/m, -      #  '\subsubsection*{\1}') +        "\\#{sect}*{\\1} +#{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}")        dob      end +    def section_heading_level_B +      section_heading_level(@dob) +    end +    def section_heading_level_C +      section_heading_level(@dob) +    end +    def section_heading_level_D +      section_heading_level(@dob) +    end +    def heading_level_1 +      heading_sublevels(@dob,:lev1) +    end +    def heading_level_2 +      heading_sublevels(@dob,:lev2) +    end +    def heading_level_3 +      heading_sublevels(@dob,:lev3) +    end      def hang        case @dob.indent        when /0/ | 
