0

I am compiling an ebook in Kannada and I would like to remove the word "Chapter" from the heading in the ebook.

The output of ebook as shown in the first image Output of ebook. However, I would want it look like in the second image Required output

Thank you in advance.

1
  • 2
    Welcome to TeX.SE. Please tell us which document class you employ and how the chapter header is generated at present: via a \chapter instruction, a \chapter* instruction, of by some other method?
    – Mico
    Jul 11, 2020 at 9:18

1 Answer 1

2

In theory, you can just change the \chaptername macro in a .cfg file:

\Preamble{xhtml}
\begin{document}
\let\chaptername\relax
\EndPreamble

This works normally, but not with this example I found:

% !TeX program = xelatex
\documentclass[justified,12.5pt]{book}
\usepackage{float}
\def\linenumberfont{\normalfont}
\usepackage{polyglossia}
\setmainfont[Script=Kannada]{Tunga}%{NudiUni01K.ttf}
\setmainlanguage{kannada}


\begin{document}
%\let\chaptername\relax

\chapter{ಪೀಠಿಕೆ}
ಆಧುನಿಕ ಬದುಕಿನ ಜ್ಞಾನ ವಿಜ್ಞಾನ ಕ್ಷೇತ್ರದಲ್ಲಿನ ಅದ್ಭುತ ಅವಿಷ್ಕಾರಗಳಲ್ಲೊಂದಾದ ಮಾಹಿತಿ ತಂತ್ರಜ್ಞಾನದ ಒಂದು ವಿನೂತನ ಪರಿಕಲ್ಪನೆ  ವಿಕಿಪೀಡಿಯಾ. ಹವಾಮಿ ಭಾಷೆಯಲ್ಲಿ ವಿಕಿ
ಎಂದರೆ ಶೀಘ್ರ ಅಥವಾ ತ್ವರಿತಗತಿ ಎಂದರ್ಥ. ಇಂಗ್ಲೀಷಿನಲ್ಲಿ ಎನ್ ಸೈಕ್ಲೊಪೀಡಿಯಾ ಎಂದರೆ ವಿಶ್ವಕೋಶ ಎಂದರ್ಥ. ಇವೆರಡೂ ಶಬ್ದಗಳನ್ನು ಸಂಯೋಜಿಸಿ 
ವಿಕಿಪೀಡಿಯಾ ಎಂಬ ಗಣಕೀಕೃತ ವಿಶ್ವಕೋಶದ ಮಾದರಿಯಲ್ಲಿ ಇದನ್ನು ಅಭಿವೃದ್ಧಿಗೊಳಿಸಲಾಗಿದೆ. ಕನ್ನಡದಲ್ಲಿ ಇದನ್ನು 'ತ್ವರಿತ ವಿಶ್ವಕೋಶ' ಎಂದು ಹೆಸರಿಸ ಬಹುದು. 
ಇದೊಂದು ಬಹುಭಾಷೀಯ ಹಾಗೂ ಅಂತರ್ಜಾಲ ಆಧಾರಿತ ವಿಶ್ವಕೋಶವಾಗಿದ್ದು,ನಿರಂತರವಾಗಿ ಪರಿಷ್ಕರಣಗೂಳ್ಳಬಲ್ಲ ಮಾಹಿತಿ ವಿತರಣ ಸಾಧನವಾಗಿದೆ.

\end{document}

I guess that the chapter name is set by Polyglossia at the begin document, so it overwrites our redefinition.

Anyway, as you want also to change the chapter number, it is easiest to use a make4ht build file. Save the following code as mybuild.lua:

local domfilter = require "make4ht-domfilter"
local number_table = {
  ["0"] = "೦",
  ["1"] = "೧",
  ["2"] = "೨",
  ["3"] = "೩",
  ["4"] = "೪",
  ["5"] = "೫",
  ["6"] = "೬",
  ["7"] = "೭",
  ["8"] = "೮",
  ["9"] = "೯",
  
}


local process = domfilter {
  function(dom)
    -- remove <br> elements from chapter
    for _, br in ipairs(dom:query_selector "h2 br") do
      local space = br:create_text_node(" ")
      br:replace_node(space)
    end
    -- -- remove text from chapter mark and convert numbers
    for _, mark in ipairs(dom:query_selector ".titlemark") do
      local titlemark = mark:get_text() or ""
      local number = titlemark:match("([%d%.]+)") or ""
      -- replace arabic number to kannada number
      local newnumber = number:gsub("%d", number_table)
      -- crete new HTML mode
      -- add space that will separate number from rest of the chapter title
      local numbernode = mark:create_text_node(newnumber .. " ")
      -- replace old text
      mark._children = {numbernode}
    end
    dom:traverse_elements(function(el)
      for _, child in ipairs(el:get_children()) do
        if child:is_text() then
          -- replace numbers in all texts
          child._text = child._text:gsub("%d", number_table)
        end
      end
    end)
    return dom
  end

}

Make:match("html$", process)

We use LUaXML DOM library to process HTML, find all chapter numbers and convert it to the correct form.

This is the result:

enter image description here

Compile using

tex4ebook -e mybuild.lua -x filename.tex
4
  • Thank you for your quick response. I tried with my file and still getting the same output. I can share the actual files with you if required.
    – ShastriD
    Jul 11, 2020 at 11:40
  • @ShastriD yes, I will need your actual file, but just small example that shows only the chapter title and your used packages
    – michal.h21
    Jul 11, 2020 at 12:08
  • Is it possible you can share your mail id and I can mail all the files ?
    – ShastriD
    Jul 11, 2020 at 12:23
  • @ShastriD sure: [email protected]
    – michal.h21
    Jul 11, 2020 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .