แสดงบทความที่มีป้ายกำกับ LaTeX แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ LaTeX แสดงบทความทั้งหมด

วันพุธ, ตุลาคม 10, 2550

en-dash และ em-dash ใน XeLaTeX

เนื่องจาก TeX ประมวลผลอินพุตไฟล์ซึ่งเป็นASCII 8-bit codepage ที่ไม่มีตัวอักษรซึ่งตรงกับ en-dash และ em-dash ทำให้ใช้ไฮเฟ่น 2 หรือ 3 อัน (--, ---) แทน. แต่เนื่องจาก XeTeX นั้นประมวลผลอินพุตเท็กส์ที่เป็นยูนิโค้ด ซึ่งมีอักขระสำหรับ en-dash และ em-dash ทำให้การใช้ --/--- จึงไม่จำเป็น
วิธีการพิมพ์ en/em-dash นั้น สำหรับวินโด้เอ๊กพี ทำได้โดย
  • เปิด Num Lock
  • กด Alt ค้าง พิมพ์ 0150 / 0151 ที่แป้น Numeric Pad ถ้าพิมพ์ที่คีย์บอร์ดธรรมดา จะไม่ติด

บันทึกเกี่ยวกับการลง TeXLive 2007 แทน MiKTeX 2.7 beta3

หลังจากเขียนดีวีดีอิมเมจที่ดาวน์โหลดมาแล้ว ลองติดตั้งดูในเครื่องคัมปานา
อินสตอเลอร์มันไม่เข้าโหมดอินสตอลให้ เนื่องจากเรามี MiKTeX ติดตั้งไว้อยู่ก่อนแล้ว
เราต้องแก้ environment variables เพื่อให้อินสตอลเลอร์มันทำงานในโหมดอินสตอล
(จริงๆแล้วสามารถโอเวอไรด์ได้ด้วยออพชั่นของคอมมานไลน์ แต่มันจะไปเขียนทัพ env var บางตัว)

env var ที่แก้คือ
  1. System Variable: Path= C:\Program Files\MiKTeX 2.7\miktex\bin;c:\program files\imagemagick-6.3.4-q16;
มันจะถามเรื่องอินสตอล Perl กับ Ghostscript

พบว่าใช้ TeXLive ดีกว่า

วันอังคาร, ตุลาคม 09, 2550

บันทึกเรื่องฟอนต์ที่ใช้ใน XeTeX in MiKTeX (installing fonts for XeTeX in MiKTeX 2.7)

ก่อนอื่นต้องรันใน fc-cache ในคอมมานด์พรอมพ์ของวินโด้
พลาดไปรันใน bash shell ของ cygwin ซะ มันเลยไม่เวิร์ค
ผลลัพธ์การรัน fc-cache -f -v แสดงข้างล่างนี้
C:/WINDOWS/Fonts: caching, 162 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1: caching, 0 fonts, 6 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/adobe: caching, 0 fonts, 2 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/adobe/courier: caching, 6 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/adobe/utopia: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/bluesky: caching, 0 fonts, 3 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/bluesky/ams: caching, 34 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/bluesky/cm: caching, 75 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/bluesky/latex-fonts: caching, 14 fonts,
0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/groff: caching, 1 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/hoekwater: caching, 0 fonts, 4 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/hoekwater/mflogo: caching, 8 fonts, 0 di
rs
C:/Program Files/MiKTeX 2.7/fonts/type1/hoekwater/misc: caching, 1 fonts, 0 dirs

C:/Program Files/MiKTeX 2.7/fonts/type1/hoekwater/rsfs: caching, 3 fonts, 0 dirs

C:/Program Files/MiKTeX 2.7/fonts/type1/hoekwater/stmaryrd: caching, 6 fonts, 0
dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/public: caching, 0 fonts, 3 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/public/eurosym: caching, 12 fonts, 0 dir
s
C:/Program Files/MiKTeX 2.7/fonts/type1/public/lm: caching, 92 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/public/xypic: caching, 9 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw: caching, 0 fonts, 9 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/avantgar: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/bookman: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/courier: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/helvetic: caching, 14 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/ncntrsbk: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/palatino: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/times: caching, 4 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/zapfchan: caching, 1 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/type1/urw/zapfding: caching, 1 fonts, 0 dirs
C:/Program Files/MiKTeX 2.7/fonts/opentype: caching, 0 fonts, 1 dirs
C:/Program Files/MiKTeX 2.7/fonts/opentype/public: caching, 0 fonts, 1 dirs
C:/Program Files/MiKTeX 2.7/fonts/opentype/public/lm: caching, 72 fonts, 0 dirs
C:/Documents and Settings/All Users/Application Data/MiKTeX/2.7/fontconfig/cache
: cleaning cache directory
fc-cache: succeeded

วันศุกร์, ตุลาคม 05, 2550

ว่าด้วยการนับเรียงของส่วนพาดหัวใน LaTeX (Numbering Heading)

REF: The LaTeX Companion, pp. 25

Every counter in LaTeX has an associated command constructed by prefixing the counter name with `\the', which generates a typeset representation of the counter in question. In case of the sectioning commands this representation form is used to produce the full number associated with the commands, as in the following definitions:
  • \renewcommand\thechapter{\arabic{chapter}}
  • \renewcommand\thesection{\thechapter.\arabic{section}}
  • \renewcommand\thesubsection{thesection.\arabic{subsection}}
This kind of recursive definition facilitates modifications to the counter representations because changes do not need to be made in more than one place. If you want to number sections using capital letters, you can just redefine the command \thesection:
  • \renewcommand\thesection{\Alph{section}}

วันพฤหัสบดี, กรกฎาคม 12, 2550

วันนี้ลองลง LyX

I installed the following programs:

MacTeX-2007 | http://www.tug.org/mactex/
MacTeX installs TeXlive and includes XeTeX which is a nice extension to support.

วันพฤหัสบดี, มีนาคม 29, 2550

ว่าด้วยเรื่องของการใช้ภาษาไทยใน TeX ด้วย XeTeX (Another solution for using Thai in TeX)

keyword: ภาษาไทย, ไทย, Thai, เรียงพิมพ์, XeTeX, LaTeX, TeX, typesetting, multilingual.

ความเป็นมา
เรื่องมันก็เริ่มขึ้นจากการหยิบหนังสือวิธีฝึกสมาธิ วิปัสสนาของท่านพุทธทาส มาอ่านในยามดึกของคืนๆหนึ่ง. แล้วเราก็นึกออกว่าเคยดาวน์โหลดไฟล์พระไตรปิฎกที่เป็นเท็กส์ไฟล์ (TIS-620) มานี่หว่า แต่ไม่เคยอ่านเลย. พอลองเปิดดูก็ปรากฏว่าอ่านไม่ได้, เลยลอง convert ไปเป็น UTF-8 ด้วย iconv ดู แล้วเปิดด้วย Eclipse ก็อ่านได้ไม่มีปัญหา. คราวนี้ก็เลยลองกูเกิ้นดู ว่าพอจะมีพระไตรปิฎกแบบที่เป็น pdf ไฟล์สวยๆบ้างมั้ยจะได้เอามาปริ้นท์อ่าน. ก็หาไม่เจอ เดาว่าคงไม่มีด้วยเลยเกิดความคิดที่จะใช้ TeX มาเรียงพิมพ์พระไตรปิฎกให้เป็นรูปร่างสวยงาม ดูน่าอ่านกว่าแบบที่เป็นเท็กส์ไฟล์

วิธีอื่นนอกจาก XeTeX
เท่าที่ลองคุ้ยๆดูในเนตก็เห็นว่ามี thai extension สำหรับ miktex ลองลงดูแล้วระบบอินสตอลของมันงี่เง่า ใช้กับ miktex-2.5 ไม่ได้ ลองแก้ Windows registry ดูจนลงได้แล้วก๊อปไฟล์ไปติดตั้งในเครื่องที่จะใช้จริง ก็เหมือนจะใช้ได้แต่มีปัญหาเรื่องฟอนต์ ก็เลยไม่ใช้ หัดใช้ XeTeX ดีกว่าเพราะสามารถใช้ภาษาอะไรก็ได้ด้วย เนื่องจากรองรับยูนิโค้ด
ต่อไปนี้เป็นบันทึกเกี่ยวกับการติดตั้ง XeTeX

การติดตั้ง
ดูได้ที่ http://www.fsci.fuk.kindai.ac.jp/kakuto/win32-ptex/web2c75-e.html (ฮิตจากการคุ้ยด้วยคีย์เวิร์ด: win32 xetex)

ก๊อปปี้ฟอนต์ที่ต้องการมาเพิ่ม
ณ ที่นี้เราก๊อปจาก Font Book ของ Mac OS X โดยฟอนต์ที่ก๊อปปี้มาคือฟอนต์ดีฟอลท์ของ Thai LaTeX ได้แก่ : Norasi, Thonburi, Loma.
ไม่แน่ใจว่ามันมีมาแต่แรกเริ่มเดิมทีหรือมาลงเองทีหลังตอนที่ลง XeTeX บนเครื่องmac.

แก้ไขไฟล์เพื่อเพิ่มฟอนต์
แก้ไฟล์ $TEX/share/texmf/fonts/conf/fonts.conf
  c:/windows/fonts
c:/myfonts
จากนั้นรันคำสั่ง
  $ fc-cache -f -v
เพื่อสร้างแคชไฟล์ใน $TEX/share/texmf/fonts/cache
ถ้าต้องการดูว่าเรามีฟอนต์อะไรใช้บ้างก็รันคำสั่ง
$ fc-list > fontlist.txt
ก็จะได้ไฟล์ fontlist.txt มาเป็น UTF-8.
รันคำสั่งเพื่อให้มันรู้ว่ามีการเพิ่มฟอนต์ใหม่เข้าไป(เมื่อแก้ fonts.conf)
    $ fc-cache -r -v
คำสั่งนี้จะเคลียร์ข้อมูลในแคชแล้วสร้างใหม่

ถ้าก๊อปปี้ไฟล์เพิ่มเข้ามาใส่ในฟอนต์ไดเรคทอรี่ก็รันคำสั่ง,
$ fc-cache -v

การกำหนดฟอนต์สำหรับแสดงผลภาษาไทย
\usepackage{fontspec} % อันนี้ยังไม่ค่อยรู้ว่าแพคเกจนี้เอาไว้ทำอะไร fontspec
% define font
\setromanfont{Norasi}
\setmonofont[Scale=0.8]{Loma}

บทความภาษาไทยที่ตามมาก็จะแสดงด้วยฟอนต์ที่ระบุไว้

วันพฤหัสบดี, มีนาคม 15, 2550

ว่าด้วยเรื่องของ LaTeX

บันทึกช่วยจำเกี่ยวกับคำสั่งต่างๆของ LaTeX
  • \secit ใช้สั่งให้เป็น italic ใน \section{This will be {\secit italic}}
  • \subsecit เหมือน \secit ข้างบนแต่ใช้ใน subsection.
  • ...