thailatex with first paragraph indent?

254 views
Skip to first unread message

Theppitak Karoonboonyanan

unread,
Mar 13, 2013, 4:31:11 AM3/13/13
to thai-linux...@googlegroups.com
สวัสดีครับ,

ประเด็นหนึ่งที่พบบ่อยจากผู้ใช้ LaTeX ก็คือ
จะทำยังไงให้ย่อหน้าแรกมันร่นเข้าไปเหมือนย่อหน้าอื่น
ซึ่งพฤติกรรมปกติของ LaTeX จะไม่ร่นย่อหน้าแรก
เข้าใจว่าเป็นธรรมเนียมของหนังสือฝรั่ง
แต่หนังสือไทยมักจะร่นทุกย่อหน้าไม่มียกเว้น
(แม้บางครั้งจะแอบเห็นบางเล่มไม่ร่นย่อหน้าแรกบ้าง)

ก็เลยคิดว่าจะพยายามรองรับเรื่องนี้ใน thailatex เลยดีไหม?

ทางเลือกต่าง ๆ ที่เป็นไปได้คือ

1. ไม่ต้องรองรับใน thailatex ให้ผู้ใช้สั่งกันเอง เช่น
- สั่ง \indent ที่ย่อหน้าแรกเสมอ
- ใช้แพกเกจ indentfirst
ซึ่งต้องเขียนเป็น FAQ เลยแหละ

2. บังคับให้ร่นย่อหน้าแรกเสมอเมื่อใช้ภาษาไทย
ตรงนี้จะมีปัญหากับคนที่ต้องการทำแบบฝรั่งจริง ๆ ไหม?

3. เพิ่ม option "indentfirst" ให้กับภาษาไทย
เมื่อเรียกใช้ babel เช่น

\usepackage[thai,indentfirst]{babel}

ซึ่งจะเปิดใช้การร่นย่อหน้าแรกให้
(การให้ดีฟอลต์ไม่ร่นย่อหน้าแรก แล้วให้ option
ไปเปิดการร่นย่อหน้าแรก ทำได้ง่ายกว่าในทางกลับกัน)

มีความเห็นว่ายังไงกันครับ?

เทพ.
--
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/

Pruet Boonma

unread,
Mar 13, 2013, 4:36:36 AM3/13/13
to thai-linux...@googlegroups.com
ภาษาอังกฤษก็มีการย่อหน้านะครับ แต่ปกติเขาจะบังคับจาก document class เอา (เช่น IEEE template ที่ผมใช้ ก็ย่อหน้าแรก) แต่ default template (เช่น article) รู้สึกว่าจะไม่ย่อหน้า  อย่างใน Microsoft words ก็มี option ใน document style ให้เลือกย่อหน้าบรรทัดแรกเหมือนกัน ดังนั้น ผมอยากให้มันเป็น option มากกว่า default นะครับ

ถ้าเป็น 3 options ดังกล่าว ผมชอบ 3 > 1> 2 ครับ 

pruet
--
คุณได้รับข้อความนี้เนื่องจากคุณสมัครรับข้อมูลจากกลุ่ม "Thai Linux/FOSS developers" ของ Google Groups
หากต้องการยกเลิกการสมัครรับข้อมูลและหยุดรับอีเมลจากกลุ่มนี้ ให้ส่งอีเมลไปที่ thai-linux-foss-...@googlegroups.com
หากต้องการโพสต์ถึงกลุ่มนี้ ให้ส่งอีเมลไปที่ thai-linux...@googlegroups.com
กรุณาเข้าสู่กลุ่มนี้ที่ http://groups.google.com/group/thai-linux-foss-devel?hl=th
หากต้องการดูตัวเลือกเพิ่มเติม กรุณาดูที่ https://groups.google.com/groups/opt_out


widhaya trisarnwadhana

unread,
Mar 13, 2013, 9:57:07 PM3/13/13
to thai-linux...@googlegroups.com
3 > 1 > 2

วิทยา

เมื่อ 13 มีนาคม 2556, 15:36, Pruet Boonma <pruet...@gmail.com> เขียนว่า:

Theppitak Karoonboonyanan

unread,
Mar 15, 2013, 4:15:46 AM3/15/13
to thai-linux...@googlegroups.com
2013/3/14 widhaya trisarnwadhana <widh...@gmail.com>:
> 3 > 1 > 2
>
> เมื่อ 13 มีนาคม 2556, 15:36, Pruet Boonma <pruet...@gmail.com> เขียนว่า:
>
>> ภาษาอังกฤษก็มีการย่อหน้านะครับ แต่ปกติเขาจะบังคับจาก document class เอา
>> (เช่น IEEE template ที่ผมใช้ ก็ย่อหน้าแรก) แต่ default template (เช่น
>> article) รู้สึกว่าจะไม่ย่อหน้า อย่างใน Microsoft words ก็มี option ใน
>> document style ให้เลือกย่อหน้าบรรทัดแรกเหมือนกัน ดังนั้น ผมอยากให้มันเป็น
>> option มากกว่า default นะครับ
>>
>> ถ้าเป็น 3 options ดังกล่าว ผมชอบ 3 > 1> 2 ครับ

ถ้าอย่างนั้น ผมขอเลือกข้อ 3 ละกันนะครับ
คือเพิ่ม option "indentfirst" ให้กับ def ภาษาไทยใน babel
อ.พฤษภ์ได้แพตช์เมื่อไรก็โพสต์มาได้เลยนะครับ

ขอบคุณครับ,

Pruet Boonma

unread,
Mar 16, 2013, 10:35:31 AM3/16/13
to thai-linux...@googlegroups.com
ผมลอง test ดู โดยใช้ file .tex ตามแนบ ได้ .dvi ตามแนบครับ ซึ่งมันย่อหน้าให้ ถ้าใช้ documentclass article ก็เลยงงว่า กรณีที่คุณเทพบอกว่าไม่ย่อหน้าให้ มันคือกรณีไหนครับ

ubuntu 12.10/thailatex 0.5.0/textlive2012
pruet


2013/3/15 Theppitak Karoonboonyanan <th...@linux.thai.net>
testthai.tex
thai.dvi

Theppitak Karoonboonyanan

unread,
Mar 16, 2013, 10:47:14 AM3/16/13
to thai-linux...@googlegroups.com
2013/3/16 Pruet Boonma <pruet...@gmail.com>:
> ผมลอง test ดู โดยใช้ file .tex ตามแนบ ได้ .dvi ตามแนบครับ ซึ่งมันย่อหน้าให้
> ถ้าใช้ documentclass article ก็เลยงงว่า กรณีที่คุณเทพบอกว่าไม่ย่อหน้าให้
> มันคือกรณีไหนครับ

ลองใส่ \section{} นะครับ ย่อหน้าแรกของ section มันจะไม่ย่อหน้า
ตามแนบครับ
testthai-sec.tex

Pruet Boonma

unread,
Mar 28, 2013, 11:04:14 AM3/28/13
to thai-linux...@googlegroups.com
คุณเทพครับ ลองดุไฟล์ patch ที่แนบมานะครับ ว่าโอเคไหม (ยังไม่ได้เขียนพวก docs นะ) 

ส่วนไฟล์ testsw.tex เป็นไฟล์ทดสอบครับ

ผมยังงง ๆ เรื่อง  \thaitext กับ \latintext นิดหน่อยว่า ลำดับมันเป็นไง แต่ \selectlanguage ใช้ได้ไม่มีปัญหาคัรบ

pruet

ปล. patch กับ trunk นะครับ


2013/3/16 Theppitak Karoonboonyanan <th...@linux.thai.net>

Theppitak Karoonboonyanan

unread,
Mar 28, 2013, 11:44:29 AM3/28/13
to thai-linux...@googlegroups.com
2013/3/28 Pruet Boonma <pruet...@gmail.com>:
> คุณเทพครับ ลองดุไฟล์ patch ที่แนบมานะครับ ว่าโอเคไหม (ยังไม่ได้เขียนพวก docs
> นะ)
>
> ส่วนไฟล์ testsw.tex เป็นไฟล์ทดสอบครับ

ไม่เจอไฟล์แนบนะครับ

Pruet Boonma

unread,
Mar 28, 2013, 11:56:32 AM3/28/13
to thai-linux...@googlegroups.com
 ลองอีกทีครับ เน็ตผมป่วงมาก หน้าจอเหมือนจะ attach  ได้แล้ว แต่ตอนส่ง มันส่งไม่ไป -_-

pruet


2013/3/28 Pruet Boonma <pruet...@gmail.com>

Pruet Boonma

unread,
Mar 28, 2013, 12:06:58 PM3/28/13
to thai-linux...@googlegroups.com
ลองอีกที จากคอมพ์อีกเครื่อง -*-

pruet
testsw.tex
thaiindentfirst.patch

Theppitak Karoonboonyanan

unread,
Mar 29, 2013, 4:31:52 AM3/29/13
to thai-linux...@googlegroups.com
2013/3/28 Pruet Boonma <pruet...@gmail.com>:
> ลองอีกที จากคอมพ์อีกเครื่อง -*-

ได้รับแล้วครับ แพตช์ดูดี ผมทดสอบแล้ว ก็ใช้การได้ครับ
แต่ช่วยปรับแพตช์ต่ออีกนิดนะครับ
- ร่นโค้ดด้วย space ไม่ใช่ tab เพื่อให้สไตล์เหมือนกับโค้ดเดิม
- อย่าลืมแต่งคำบรรยายแทนตรง Lorem ด้วยนะครับ
- ชื่อ option ขอปรับเป็น thaiindentfirst เพื่อให้สอดคล้องกับ option
thainumber ที่มีอยู่เดิม (ของภาษาสเปนเขาใช้ es-* แต่ของเรา
จะเป็น th-* หรือ thai* ก็ไม่ได้ยาวต่างกันเท่าไร)

>> 2013/3/28 Pruet Boonma <pruet...@gmail.com>
>>>
>>> ผมยังงง ๆ เรื่อง \thaitext กับ \latintext นิดหน่อยว่า ลำดับมันเป็นไง แต่
>>> \selectlanguage ใช้ได้ไม่มีปัญหาคัรบ

ตรง \thaitext กับ \latintext เอาไว้ก่อนก็ได้ครับ
ความจริงจุดประสงค์เริ่มแรกเพื่อใช้สลับฟอนต์เท่านั้น
ของภาษาอื่นเขาก็ทำแค่เรื่องฟอนต์เหมือนกัน

ขอบคุณครับ,

Pruet Boonma

unread,
Mar 29, 2013, 12:10:00 PM3/29/13
to thai-linux...@googlegroups.com
แก้ไขตามคำแนะนำของคุณเทพครับ

pruet


2013/3/29 Theppitak Karoonboonyanan <th...@linux.thai.net>
thaiindentfirst.patch

Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 1:04:10 AM3/31/13
to thai-linux...@googlegroups.com
On Fri, Mar 29, 2013 at 11:10:00PM +0700, Pruet Boonma wrote:
> แก้ไขตามคำแนะนำของคุณเทพครับ

มี comment เพิ่มเติมครับ:

> Index: babel/thai.dtx
> ===================================================================
> --- babel/thai.dtx (revision 459)
> +++ babel/thai.dtx (working copy)
> @@ -621,6 +621,46 @@
> % \end{macrocode}
> % \end{macro}
> %
> +% \subsubsection{\Lopt{thaiindentfirst} option}
> +% As suggested by English writting guideline, the first paragraph in each

"writing guideline" (ตัว t เกินมา)

> +% section shall not be indented. However, for Thai language, indenting the
> +% first paragraph is more popular and widely suggested.
> +% If \Lopt{thaiindentfirst} is supplied in the |\usepackage| command, the
> +% first Thai paragraph in each section will be indented. The other
> +% paragraphs will behave as default.
> +%
> +% \begin{macrocode}
> +\DeclareOption{thaiindentfirst} {%
> +% \end{macrocode}
> +%
> +% We need to save original \@afterindentfalse, so create a pointer to point
> +% to it.

คำสั่ง \let ไม่ใช่การกำหนด pointer แต่เป็นการ assign ค่าปัจจุบัน น่าจะปรับเป็นทำนองว่า
"create variable to store its original value"

> +%
> +% \begin{macrocode}
> + \let\th@afterindentfalse\@afterindentfalse
> +% \end{macrocode}

ผมคิดว่าโค้ดส่วนนี้น่าจะไปอยู่ใน \extrasthai นะครับ คือไม่ใช่ว่าเก็บค่าครั้งเดียวตอนโหลด
babel แต่น่าจะเก็บค่าตอนที่ switch เข้าภาษาไทย เผื่อว่ามีภาษาอื่นกำหนด \@afterindentfalse
เอาไว้ (เช่น ภาษาสเปน) ตอน switch ออกจะได้คืนค่าก่อนเข้า ไม่ใช่ค่าเริ่มแรก

> +%
> +% When switching to Thai language, point \@afterindentfalse to
> +% \@afterindentrue, so when latex will be unable to indent the first
> +% paragraph,

- point -> set
- latex -> \LaTeX\
- so when -> so that
- will be unable to -> will never (?)

> +%
> +% \begin{macrocode}
> + \addto\extrasthai{%
> + \let\@afterindentfalse\@afterindenttrue
> + \@afterindenttrue
> + }
> +% \end{macrocode}
> +%
> +% When switching out of Thai language, point \@afterindentfalse
> +% back to its original function.

- point -> set/restore
- original function -> original value

> +%
> +% \begin{macrocode}
> + \addto\noextrasthai{%
> + \let\@afterindentfalse\th@afterindentfalse
> + }
> +}
> +% \end{macrocode}
> +%
> % \subsubsection{\Lopt{thainumber} option}
> %
> % Not all Thai documents use Thai digits. So, we support this as an

Pruet Boonma

unread,
Mar 31, 2013, 1:24:56 AM3/31/13
to thai-linux...@googlegroups.com



2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>
On Fri, Mar 29, 2013 at 11:10:00PM +0700, Pruet Boonma wrote:
> แก้ไขตามคำแนะนำของคุณเทพครับ

มี comment เพิ่มเติมครับ:

คำสั่ง \let ไม่ใช่การกำหนด pointer แต่เป็นการ assign ค่าปัจจุบัน น่าจะปรับเป็นทำนองว่า
"create variable to store its original value"

ตรงนี้ผมเข้าใจว่า \@afterindentfalse เป็น function ดังนั้น \let จึงเป็นการเปลี่ยน ค่า pointer ที่ชี้ไปยัง function นะครับ 


> +%
> +%    \begin{macrocode}
> +  \let\th@afterindentfalse\@afterindentfalse
> +%    \end{macrocode}

ผมคิดว่าโค้ดส่วนนี้น่าจะไปอยู่ใน \extrasthai นะครับ คือไม่ใช่ว่าเก็บค่าครั้งเดียวตอนโหลด
babel แต่น่าจะเก็บค่าตอนที่ switch เข้าภาษาไทย เผื่อว่ามีภาษาอื่นกำหนด \@afterindentfalse
เอาไว้ (เช่น ภาษาสเปน) ตอน switch ออกจะได้คืนค่าก่อนเข้า ไม่ใช่ค่าเริ่มแรก

ตอนแรกผมก็เอาไปไว้ใน \extrasthai นะครับ แต่บางทีผม trace ดูก็พบว่า มันมีการเรียก \noextrasthai โดยที่ไม่เรียก \extrasthai  (ซึ่งไม่น่าจะเป็นไปได้?) ทำให้ คำสั่ง   \let\@afterindentfalse\th@afterindentfalse  ทำงานผิดพลาด

เดี๋ยวขอเช็คประเด็นนี้อีกนิดนะครับ ถ้าเป็นความผิดพลาดจากการ debug ของผมเอง เดี๋ยวจะแก้ตามคำแนะนำครับ  

pruet





Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 3:33:00 AM3/31/13
to thai-linux...@googlegroups.com
2013/3/31 Pruet Boonma <pruet...@gmail.com>:
>
> 2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>
>>
>> คำสั่ง \let ไม่ใช่การกำหนด pointer แต่เป็นการ assign ค่าปัจจุบัน
>> น่าจะปรับเป็นทำนองว่า
>> "create variable to store its original value"
>
> ตรงนี้ผมเข้าใจว่า \@afterindentfalse เป็น function ดังนั้น \let
> จึงเป็นการเปลี่ยน ค่า pointer ที่ชี้ไปยัง function นะครับ

โอเคครับ ตรงนี้น่าจะเป็นอย่างที่ อ.พฤษภ์ ว่า

>> > +%
>> > +% \begin{macrocode}
>> > + \let\th@afterindentfalse\@afterindentfalse
>> > +% \end{macrocode}
>>
>> ผมคิดว่าโค้ดส่วนนี้น่าจะไปอยู่ใน \extrasthai นะครับ
>> คือไม่ใช่ว่าเก็บค่าครั้งเดียวตอนโหลด
>> babel แต่น่าจะเก็บค่าตอนที่ switch เข้าภาษาไทย เผื่อว่ามีภาษาอื่นกำหนด
>> \@afterindentfalse
>> เอาไว้ (เช่น ภาษาสเปน) ตอน switch ออกจะได้คืนค่าก่อนเข้า ไม่ใช่ค่าเริ่มแรก
>
> ตอนแรกผมก็เอาไปไว้ใน \extrasthai นะครับ แต่บางทีผม trace ดูก็พบว่า
> มันมีการเรียก \noextrasthai โดยที่ไม่เรียก \extrasthai
> (ซึ่งไม่น่าจะเป็นไปได้?) ทำให้ คำสั่ง
> \let\@afterindentfalse\th@afterindentfalse ทำงานผิดพลาด

คิดดูแล้วไม่น่าเป็นไปได้ครับ ไม่งั้นมันจะเซ็ตฟอนต์อะไรตอนไหน?

> เดี๋ยวขอเช็คประเด็นนี้อีกนิดนะครับ ถ้าเป็นความผิดพลาดจากการ debug ของผมเอง
> เดี๋ยวจะแก้ตามคำแนะนำครับ

โอเคครับ

Pruet Boonma

unread,
Mar 31, 2013, 3:59:02 AM3/31/13
to thai-linux...@googlegroups.com
ตรวจสอบ และแก้ไขตามที่คุณเทพแจ้งแล้วครับ

pruet


2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>

Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 7:49:47 AM3/31/13
to thai-linux...@googlegroups.com
2013/3/31 Pruet Boonma <pruet...@gmail.com>:
> ตรวจสอบ และแก้ไขตามที่คุณเทพแจ้งแล้วครับ

แพตช์ไม่มาน่ะครับ

Pruet Boonma

unread,
Mar 31, 2013, 10:05:52 AM3/31/13
to thai-linux...@googlegroups.com
=_=  ลองใหม่สิครับ

pruet


2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>
2013/3/31 Pruet Boonma <pruet...@gmail.com>:
thaiindentfirst.patch

Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 10:51:17 AM3/31/13
to thai-linux...@googlegroups.com
On Sun, Mar 31, 2013 at 09:05:52PM +0700, Pruet Boonma wrote:
> =_= ลองใหม่สิครับ

มาแล้วครับ:


> Index: babel/thai.dtx
> ===================================================================
> --- babel/thai.dtx (revision 459)
> +++ babel/thai.dtx (working copy)
> @@ -621,6 +621,41 @@
> % \end{macrocode}
> % \end{macro}
> %
> +% \subsubsection{\Lopt{thaiindentfirst} option}
> +% As suggested by English writing guideline, the first paragraph in each
> +% section shall not be indented. However, for Thai language, indenting the
> +% first paragraph is more popular and widely suggested.
> +%
> +% If \Lopt{thaiindentfirst} is supplied in the |\usepackage| command, the
> +% first Thai paragraph in each section will be indented. The other
> +% paragraphs will behave as default.
> +%
> +% \begin{macrocode}
> +\DeclareOption{thaiindentfirst} {%
> +% \end{macrocode}
> +%
> +% When switching to Thai language, point \@afterindentfalse to
> +% \@afterindentrue, so that \LaTeX\ will never indent the first
> +% paragraph.
> +%
> +% \begin{macrocode}
> + \addto\extrasthai{%
> + \let\th@afterindentfalse\@afterindentfalse
> + \let\@afterindentfalse\@afterindenttrue
> + \@afterindenttrue
> + }
> +% \end{macrocode}
> +%
> +% When switching out of Thai language, point \@afterindentfalse
> +% back to its original function.
> +%
> +% \begin{macrocode}
> + \addto\noextrasthai{%
> + \let\@afterindentfalse\th@afterindentfalse
> + }
> +}
> +% \end{macrocode}

บรรทัดนี้ยังใช้ tab ร่นโค้ดอยู่ ซึ่งทำให้เอกสาร thai.pdf ที่สร้างออกมา
มีโค้ดข้างล่างนี้หลงเหลืออยู่

> +%
> % \subsubsection{\Lopt{thainumber} option}
> %
> % Not all Thai documents use Thai digits. So, we support this as an

เรื่องอื่น ๆ น่าจะโอเคแล้วนะครับ แต่พอตรวจเอกสาร thai.pdf ที่สร้างออกมาแล้ว
พบว่าโค้ดที่แทรกเข้ามา ไปตกอยู่กลาง section 1.8 Thai numbering support
โดยมาแทรกระหว่าง macro ที่ใข้แปลงตัวเลข กับการ \DeclareOption{thainumber}

คงต้องเลื่อนขึ้นไปแทรกก่อนหน้า \subsection{Thai numbering support} แทนนะครับ

แล้วก็น่าจะต้องเขียนอธิบายผู้ใช้ในระหว่าง section 1.2 กับ 1.3 ด้วยนะครับ
(ตรงที่แพตช์นี้ เป็น document สำหรับ implementation ครับ)

ขอบคุณครับ,

Pruet Boonma

unread,
Mar 31, 2013, 11:21:18 AM3/31/13
to thai-linux...@googlegroups.com
มาแล้วครับ :3

pruet


2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>
On Sun, Mar 31, 2013 at 09:05:52PM +0700, Pruet Boonma wrote:
thaiindentfirst.patch

Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 11:59:47 AM3/31/13
to thai-linux...@googlegroups.com
2013/3/31 Pruet Boonma <pruet...@gmail.com>:
> มาแล้วครับ :3

commit แล้วครับ:

http://linux.thai.net/websvn/wsvn/software.thailatex/trunk/?rev=460

เอ.. อ.พฤษภ์ มี svn account หรือยังนะครับ?

Theppitak Karoonboonyanan

unread,
Mar 31, 2013, 12:17:00 PM3/31/13
to thai-linux...@googlegroups.com
2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>:
ผมปรับเพิ่มอีกนิดหน่อยนะครับ
- wrap บรรทัดที่ 80 คอลัมน์
- ใช้ space 2 เคาะ หลัง fullstop
- ครอบ \@afterindent... ใน doc ให้เป็น verbatim

http://linux.thai.net/websvn/wsvn/software.thailatex/trunk/?rev=462

Pruet Boonma

unread,
Mar 31, 2013, 12:19:15 PM3/31/13
to thai-linux...@googlegroups.com
ขอบคุณคุณเทพที่ชี้แนะครับ :D 

svn account ถ้ามี ก็คงลืมไปแล้วคัรบ -_-

pruet


2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>
2013/3/31 Theppitak Karoonboonyanan <th...@linux.thai.net>:
Reply all
Reply to author
Forward
0 new messages