LaTeX/Định dạng Văn bản

Từ testwiki
Bước tới điều hướng Bước tới tìm kiếm

Bản mẫu:Đang viết


Bản mẫu:LaTeX/Bottom

Bản mẫu:LaTeX/Top

Phần này sẽ hướng dẫn bạn các kỹ thuật định dạng văn bản. Định dạng cho phép xử lý đa số thứ liên quan đến giao diện bao gồm kiểu văn bản và khoảng cách. Định dạng cũng có thể cập đến bố cục đoạn văn và trang, ở đây chúng tôi sẽ tập trung vào việc tùy chỉnh từ và câu.

Người dùng sử dụng các kỹ thuật định dạng để phân biệt các yếu tố văn bản với phần còn lại của văn bản. Có nhiều cách mà chúng ta muốn phân biệt các yếu tố văn bản đã tạo ra nhiều kỹ thuật định dạng. In nghiêng thường được sử dụng để nhấn mạnh các từ hoặc cụm từ chính. Chú thích cuối trang rất hữu ích để cung cấp thêm thông tin hoặc làm rõ mà không làm gián đoạn dòng chính của văn bản. Vì những lý do này, định dạng là rất quan trọng. Tuy nhiên, định dạng cũng rất dễ bị lạm dụng, và một tài liệu có quá nhiều định dạng sẽ khiến người đọc rối mắt hoặc gây mất thẩm mỹ.

LaTeX linh hoạt cho phép bạn có nhiều quyền kiểm soát hơn đối với việc trình bày tài liệu. Phải nói rằng, một trong những mục đích của LaTeX là loại bỏ sự căng thẳng khi bạn có thể tự tay xử lý cách trình bày.

Khoảng trắng

Khoảng trắng dòng

Nếu bạn muốn dùng 1 khoảng trắng lớn hơn giữa các dòng (giãn dòng) trong 1 tài liệu, bạn có thể thay đổi giá trị này lệnh Bản mẫu:LaTeX/Usage

ở phần đầu tài liệu. Sử dụng Bản mẫu:LaTeX/LaTeX cho khoảng cách dòng "1.5", và Bản mẫu:LaTeX/LaTeX cho khoảng cách dòng đôi. Thông thường các dòng không tự động giãn nhau với độ giãn mặc định là 1. Điều này đôi khi không lý tưởng cho tất cả các trường hợp xem lý do.

Gói Bản mẫu:LaTeX/Package cho phép điều khiển độ giãn dòng mịn hơn. Ví dụ, thiết lập độ giãn dòng "1.5" nhưng không phải ở những chỗ không cần thiết như chú thích chân trang (footnote) hay nhãn:

Bản mẫu:LaTeX/Usage

Để thay đổi khoảng trắng dòng bên trong tài liệu, gói setspace cung cấp môi trường singlespace, onehalfspace, doublespacespacing:

Bản mẫu:LaTeX/Usage

Bản mẫu:Warning

Khoảng trắng không bị phá vỡ (non-breaking space)

Tính năng thiết yếu này hơi lạ đối với những người mới sử dụng, mặc dù tính năng này có sẵn trên hầu hết các bộ xử lý tài liệu WYSIWYG. Khoảng cách không bị phá vỡ giữa hai token (ví dụ: từ, dấu chấm câu) ngăn bộ xử lý chèn dấu ngắt dòng giữa chúng. Ngoài ra, không thể mở rộng khoảng trống không bị phá vỡ. Điều này rất quan trọng để đọc tài liệu một cách đồng nhất.

LaTeX sử dụng ký hiệu '~' làm khoảng trắng không bị phá vỡ. Bạn thường sử dụng khoảng trắng không bị phá vỡ cho dấu câu trong một số ngôn ngữ, cho đơn vị và tiền tệ, cho tên viết tắt, v.v. Trong kiểu chữ tiếng Pháp, bạn sẽ đặt một khoảng trắng không bị phá vỡ trước tất cả các dấu chấm câu hai phần.

Các ví dụ: Bản mẫu:LaTeX/Usage

Sentence-spacing -- space between words and sentences

To get a straight right margin in the output, LaTeX inserts varying amounts of space between the words. By default, it follows traditional typesetting practice and inserts more space at the end of a sentence to assist the reader: an em-space rather than a word-space. This can be approximated on a typewriter or computer keyboard by pressing the space bar twice rather than once. After the invention of the typewriter, English practice was to press the spacebar twice between sentences (but not around various other punctuation), while French practice was to press the spacebar once (but then also again around various other punctuation).

The extra space added at the end of sentences is latterly considered typographically old-fashioned in current mass-market English language printing. The practice was discovered in the fifteenth century to be preferred by readers and remained the standard throughout the fifteenth to twentieth centuries. Typesetting technology changes around WWII encouraged mass-market publishers to increasingly use single spacing for cost/profit reasons, and in the late 1980s the then-innovative Macintosh DTP technology created a suddenly wide platform for the University of Chicago Press to reintroduce and evangelize William Morris's failed nineteenth century attempt to popularize the rejected early fifteenth century's close-set type as a Norm, but this time to people without industry or market knowledge. "French Spacing" was redefined at this time in the USA (only) as a pejorative term to describe its opposite: to mean em-spacing between sentences rather than word-spacing. LaTeX users should note that Donald Knuth created TeX specifically to correct what he described as the ugliness and unreadability of then-(70s, pre-MacintoshDTP)-machine-typesetting, that he later added the FrenchSpacing option not as default but as a lengthily-specified option, i.e. that original TeX assumed the user wanted reader-centric typesetting (em-spacing sentences not word-spacing), and that Donald Knuth explicitly coded the FrenchSpacing option to implement precisely the opposite of what current post-University-of-Chicago typographers declare it to mean despite him being "otherwise" regarded as extremely intelligent and extremely well informed.) Most modern typesetters treat the end of sentence space the same as the interword space. (See for example, Bringhurst's Elements of Typographic Style.)

The additional space after periods can be disabled with the command

Bản mẫu:LaTeX/Usage

which tells LaTeX not to insert more space after a period than after ordinary character. Frenchspacing can be turned off later in your document via the Bản mẫu:LaTeX/LaTeX command.

If an author wishes to use the wider end-of-sentence spacing, care must be exercised so that punctuation marks are not misinterpreted as ends of sentences. TeX assumes that sentences end with periods, question marks or exclamation marks. Although if a period follows an uppercase letter, this is not taken as a sentence ending, since periods after uppercase letters normally occur in abbreviations. Any exception from these assumptions has to be specified by the author. A backslash before a space generates a space that will not be enlarged. A tilde ‘Bản mẫu:LaTeX/LaTeX’ character generates a non-breaking space. The command Bản mẫu:LaTeX/LaTeX before a period specifies that this period terminates a sentence even when it follows an uppercase letter. (If you are using Bản mẫu:LaTeX/LaTeX, then none of these exceptions need be specified.)

Stretched spaces

You can insert a horizontal stretched space with Bản mẫu:LaTeX/LaTeX in a line so that the rest gets "pushed" toward the right margin. For instance this may be useful in the header. Bản mẫu:LaTeX/Usage

Similarly you can insert vertical stretched space with Bản mẫu:LaTeX/LaTeX. It may be useful for special pages. Bản mẫu:LaTeX/Usage

See Lengths for more details.

Khoảng trắng thủ công

Khoảng cách giữa các từ và câu, giữa các đoạn văn, phần, tiểu mục, v.v. được xác định tự động bởi LaTeX. Việc chèn khoảng trắng theo cách thủ công là trái với triết lý của LaTeX và thường sẽ dẫn đến định dạng không hợp lệ. Giãn cách thủ công là vấn đề viết macro và tạo gói.

Xem Độ dài để biết thêm chi tiết.

Dấu gạch nối

LaTeX gạch nối các từ bất cứ khi nào cần thiết. Quy tắc gạch nối đối với các ngôn ngữ khác nhau sẽ khác nhau. Theo mặc định, LaTeX chỉ hỗ trợ tiếng Anh, vì vậy nếu bạn muốn có các quy tắc gạch nối chính xác với một ngôn ngữ mong muốn, tham khảo Quốc tế hóa.

If the hyphenation algorithm does not find the correct hyphenation points, you can remedy the situation by using the following commands to tell TeX about the exception. The command Bản mẫu:LaTeX/Usage causes the words listed in the argument (separated by blanks) to be hyphenated only at the points marked by “-”. The argument of the command should only contain words built from normal letters, or rather characters that are considered to be normal letters by LaTeX. It is known that the hyphenation algorithm does not find all correct American English hyphenation points for several words. A log of known exceptions is published periodically in the TUGboat journal. (2012 list: https://www.tug.org/TUGboat/tb33-1/tb103hyf.pdf).

The hyphenation hints are stored for the language that is active when the hyphenation command occurs. This means that if you place a hyphenation command into the preamble of your document it will influence the English language hyphenation. If you place the command after the Bản mẫu:LaTeX/LaTeX and you are using some package for national language support like babel, then the hyphenation hints will be active in the language activated through babel. The example below will allow “hyphenation” to be hyphenated as well as “Hyphenation”, and it prevents “FORTRAN”, “Fortran” and “fortran” from being hyphenated at all. No special characters or symbols are allowed in the argument. Example: Bản mẫu:LaTeX/Usage With babel, the recommended command to set hyphenation exceptions is Bản mẫu:LaTeX/LaTeX. When LuaTeX is used, babel also allows to add new patterns and modify existing ones (with Bản mẫu:LaTeX/LaTeX), as well as to define non-standard rules (like ‘ff’ to ‘ff-f’ in some languages, or ranked hyphenation) to be applied without explicit mark-up (with Bản mẫu:LaTeX/LaTeX).

The command Bản mẫu:LaTeX/LaTeX inserts a discretionary hyphen into a word. This also becomes the only point where hyphenation is allowed in this word. This command is especially useful for words containing special characters (e.g., accented characters), because LaTeX does not automatically hyphenate words containing special characters. Bản mẫu:LaTeX/Example

LaTeX does not hyphenate compound words that contain a dash[1]. There are two packages that can add back flexibility. The Bản mẫu:LaTeX/Package package supplies the Bản mẫu:LaTeX/LaTeX command. This command typesets the dash and then subjects the constituent words to automatic hyphenation. After loading the package: Bản mẫu:LaTeX/Usage

one should write, instead of electromagnetic-endioscopy: Bản mẫu:LaTeX/Usage

The Bản mẫu:LaTeX/Package package also offers features for controlling the hyphenation of compound words containing dashes — as opposed to the words themselves which it leaves to LaTeX. The Bản mẫu:LaTeX/LaTeX option enables a more compressed syntax: Bản mẫu:LaTeX/Usage

Typical usage is as follows, assuming the compressed syntax. In both cases, LaTeX can break and hyphenate the constituent words, but in the latter case, it will not break after the L: Bản mẫu:LaTeX/Usage

One or more words can be kept together on the one line with the standard LaTeX command: Bản mẫu:LaTeX/Usage

This prevents hyphenation and causes its argument to be kept together under all circumstances. For example: Bản mẫu:LaTeX/Usage

Bản mẫu:LaTeX/LaTeX is similar to Bản mẫu:LaTeX/LaTeX, but in addition there will be a visible box drawn around the content.

To avoid hyphenation altogether, the penalty for hyphenation can be set to an extreme value: Bản mẫu:LaTeX/Usage

You can change the degree to which LaTeX will hyphenate by changing the value of Bản mẫu:LaTeX/LaTeX and Bản mẫu:LaTeX/LaTeX. You'll have to experiment with the values to achieve the desired effect. A document which has a low tolerance value will cause LaTeX not to tolerate uneven spacing between words, hyphenating words more frequently than in documents with higher tolerances. Also note that using a higher text width will decrease the probability of encountering badly hyphenated word. For example adding Bản mẫu:LaTeX/Usage will widen the text width and reduce the amount of margin overruns.

Quote-marks

LaTeX treats left and right quotes as different entities. For single quotes, a grave accent, ` (on American keyboards, this symbol is found on the tilde key; adjacent to the number 1 key on most keyboards) gives a left quote mark, and an apostrophe, ' gives a right. For double quotes, simply double the symbols, and LaTeX will interpret them accordingly. (Don't use the " for right double quotes: when the babel package is used for some languages (e.g. German), the " is redefined to produce an umlaut accent; using " for right double quotes will either lead to bad spacing or it being used to produce an umlaut). On British keyboards, ' ` ' is left of the ' 1 ' key and shares the key with ' ¬ ', and sometimes ' ¦ ' or ' | '. The apostrophe (') key is to the right of the colon/semicolon key and shares it with the ' @ ' symbol.


Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

Bản mẫu:LaTeX/LaTeX

The right quote is also used for apostrophe in LaTeX without trouble.

For left bottom quote and European quoting style you need to use T1 font encoding enabled by: Bản mẫu:LaTeX/Usage

See Fonts for more details on font encoding.

The package Bản mẫu:LaTeX/Package offers a multilingual solution to quotations, with integration to citation mechanisms offered by BibTeX. This package allows one for example to switch languages and quotation styles according to babel language selections.

Diacritics and accents

Most accents and diacritics may be inserted with direct keyboard input by configuring the preamble properly. For symbols unavailable on your keyboard, diacritics may be added to letters by placing special escaped metacharacters before the letter that requires the diacritic.

See Special Characters.

Margin misalignment

Some very long words, numbers or URLs may not be hyphenated properly and move far beyond the side margin. One solution for this problem is to use Bản mẫu:LaTeX/Environment environment, which tells LaTeX to adjust word spacing less strictly. As a result, some spaces between words may be a bit too large, but long words will be placed properly.

Bản mẫu:LaTeX/Example

Another solution is to edit the text to avoid long words, numbers or URLs approaching the side margin.

Ligatures

Some letter combinations are typeset not just by setting the different letters one after the other, but by actually using special symbols (like "ff"), called Bản mẫu:W. Ligatures can be prohibited by inserting Bản mẫu:LaTeX/LaTeX or, if this does not work, Bản mẫu:LaTeX/LaTeX between the two letters in question. This might be necessary with words built from two words. A classic example is shelfful:[2]

Bản mẫu:LaTeX/Example

If you are using LuaLaTeX, you can automate some of this work with the Bản mẫu:LaTeX/Package package.

Slash marks

When the slash character Bản mẫu:LaTeX/LaTeX is immediately preceded and/or followed by text without intervening white space, LaTeX does not allow a line break to occur between the slash and adjacent text. This behaviour was implemented because historically most occurrences of the slash within text were situations where the convention was to keep the surrounding text together on one line. Examples include

Dates and unit abbreviations are relatively short, so the constraint that they must be kept together on a single line does not cause issues. However, the Bản mẫu:LaTeX/LaTeX character can also occur in longer expressions which might create "overfull" errors in output, causing text to overflow a margin. In these situations the Bản mẫu:LaTeX/LaTeX character should be replaced by "Bản mẫu:LaTeX/LaTeX", which allows the line to "break" after the slash mark if needed. Examples include

  • Words separated by slashes, such as "input/output" which should be typeset as "Bản mẫu:LaTeX/LaTeX", or Yes/No/Cancel. (Shorter examples like and/or could be safely left as not allowing a line break.)
  • Directory names in operating systems that use the slash as a separator, such as /home/texlion/Documents, which should be typeset as "Bản mẫu:LaTeX/LaTeX". Note that the first of the 3 slashes is NOT replaced.

A word after Bản mẫu:LaTeX/LaTeX or Bản mẫu:LaTeX/LaTeX is not automatically hyphenated. This is a similar problem to non-hyphenation of words with a dash described under Hyphenation. One way to have both a line break and automatic hyphenation in both words is Bản mẫu:LaTeX/Usage Both Bản mẫu:LaTeX/LaTeX and Bản mẫu:LaTeX/LaTeX can be used with a zero Bản mẫu:LaTeX/LaTeX like this. Bản mẫu:LaTeX/LaTeX includes a penalty to make a line break there less desirable. This combination can be made into a new slash macro if desired. The Bản mẫu:LaTeX/Package package includes an Bản mẫu:LaTeX/LaTeX which will add a hyphen after the slash like "input/- output" if the line breaks there.

Phông chữ

Để thay đổi họ phông chữ, nhấn mạnh văn bản và các vấn đề khác liên quan đến phông chữ, hãy xem Phông chữ.

Formatting macros

Even if you can easily change the output of your fonts using those commands, you're better off not using explicit commands like this, because they work in opposition to the basic idea of LaTeX, which is to separate the logical and visual markup of your document. This means that if you use the same font changing command in several places in order to typeset a special kind of information, you should use Bản mẫu:LaTeX/LaTeX to define a "logical wrapper command" for the font changing command.

Bản mẫu:LaTeX/Example

This approach has the advantage that you can decide at some later stage that you want to use some visual representation of danger other than Bản mẫu:LaTeX/LaTeX, without having to wade through your document, identifying all the occurrences of Bản mẫu:LaTeX/LaTeX and then figuring out for each one whether it was used for pointing out danger or for some other reason.

See Macros for more details.

Chế độ văn bản chỉ số trên (superscript) và chỉ số dưới (subscript)

Viết chỉ số trên và chỉ số dưới được thực hiện đơn giản bằng cách sử dụng Bản mẫu:LaTeX/LaTeXBản mẫu:LaTeX/LaTeX.

Bản mẫu:LaTeX/Usage

Lưu ý: Cần có phiên bản LaTeX từ 2015 trở lên hoặc gói fixltx2e để sử dụng các chế độ văn bản chỉ số dưới trong mọi ngữ cảnh.[3]

Text figures ("old style" numerals)

Bản mẫu:Info

Many typographers prefer to use titling figures, sometimes called lining figures, when numerals are interspersed with full caps, when they appear in tables, and when they appear in equations, using text figures elsewhere. LaTeX allows this usage through the Bản mẫu:LaTeX/LaTeX command:

Bản mẫu:LaTeX/Usage

Some fonts do not have text figures built in; the Bản mẫu:LaTeX/Environment package attempts to remedy this by effectively generating text figures from the currently-selected font. Put Bản mẫu:LaTeX/LaTeX in your preamble. Bản mẫu:LaTeX/Environment also allows you to use decimal points, properly formatted dollar signs, etc. within Bản mẫu:LaTeX/LaTeX.

One common use for text figures is in section, paragraph, and page numbers. These can be set to use text figures by placing some code in your preamble:

Bản mẫu:LaTeX/Usage

Should you use additional sectioning or paragraphing commands, you may adapt the previous code listing to include them as well.

Note

A subsequent use of the Bản mẫu:LaTeX/LaTeX command, e.g., Bản mẫu:LaTeX/LaTeX, will reset the Bản mẫu:LaTeX/LaTeX command back to the original. Thus, if you use the Bản mẫu:LaTeX/LaTeX command in your document, be sure to reinstate your Bản mẫu:LaTeX/LaTeX from the code above:

Bản mẫu:LaTeX/Usage

Dấu gạch ngang và dấu gạch nối

LaTeX có 4 dạng dấu gạch: gạch nối (-), en dash (–), em dash (—), hoặc dấu trừ (−). Bạn có thể biểu thị 3 dấu gạch ngang đầu tiên với số lượng liên tiếp khác nhau. Dấu hiệu thứ tư thực ra không phải là dấu gạch ngang—nó là dấu trừ trong toán học:

Bản mẫu:LaTeX/Example

Tên gọi các dấu gạch là: ‘-’(-) hyphen , ‘--’(–) en-dash , ‘---’(—) em-dash và dấu trừ ‘’(−). Chúng có các mục đích khác nhau:

Input Output Purpose
- - inter-word
-- page range, 1–10
--- punctuation dash—like this
$-$ minus sign

Sử dụng Bản mẫu:LaTeX/LaTeX từ gói Bản mẫu:LaTeX/Package thay vì gạch nối nếu bạn muốn LaTeX ngắt các từ ghép giữa các dòng.

Các lệnh Bản mẫu:LaTeX/LaTeXBản mẫu:LaTeX/LaTeX được dùng để tạo en-dash (–), và em-dash (—) tương ứng.

Dấu chấm lửng (…)

Một chuỗi ba dấu chấm được gọi là Bản mẫu:W (dấu ba chấm, tiếng Anh là ellipsis), thường được sử dụng để chỉ ra văn bản bị bỏ qua.

Trên máy đánh chữ, dấu phẩy hoặc dấu chấm chiếm cùng một khoảng không gian như bất kỳ chữ cái nào khác.

Trong việc in ấn sách, những ký tự này chỉ chiếm một ít không gian và được đặt rất gần với ký tự đứng trước. Do đó, bạn không thể nhập 'dấu chấm lửng' bằng cách nhập ba dấu chấm liên tiếp nhau, vì lúc đó khoảng cách giữa các dấu chấm sẽ không đúng. Thay vào đó, có một lệnh đặc biệt cho những dấu chấm này. Nó được gọi là Bản mẫu:LaTeX/LaTeX:

Bản mẫu:LaTeX/Example

Ngoài ra, bạn có thể sử dụng lệnh Bản mẫu:LaTeX/LaTeX để cho phép thay đổi khoảng cách giữa các dấu chấm.

Các chuỗi làm sẵn

Có một số lệnh LaTeX rất đơn giản để sắp chữ các chuỗi văn bản đặc biệt:

Bản mẫu:- Bản mẫu:TODO

Chú thích và tham khảo

Bản mẫu:Reflist Bản mẫu:A-Roberts


Bản mẫu:LaTeX/Bottom


ru:LaTeX/Форматирование текста sr:LateX/Форматирање текста

  1. Bản mẫu:LaTeX/Package package documentation, p3
  2. Bản mẫu:Cite book
  3. http://tex.stackexchange.com/questions/1013/how- to-typeset-subscript-in-usual-text-mode