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 . However, I would want it look like in the second image
Thank you in advance.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIn 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:
Compile using
tex4ebook -e mybuild.lua -x filename.tex
\chapter
instruction, a\chapter*
instruction, of by some other method?