latex font:LaTeX Typesetting (3): Typesetting-Font Tutorial免费ppt模版下载-道格办公

LaTeX Typesetting (3): Typesetting

This typesetting function. In LaTeX, typesetting text is not just simple writing, you can also control the format, style and layout of the text through various commands and environments. The following will introduce some commonly used typesetting commands

This series introduces basic formatting in LaTeX. Part 1 introduced lists. Section 2 explains the tables. In Part 3, you'll learn about another important feature of LaTeX: delicate and flexible document layout. This article describes how to customize page layouts, tables of contents, header sections, and page styles.

Page dimensions

When you first wrote a LaTeX document, you may have noticed that the default margins are a bit larger than you thought. Margins are relative to the specified paper type, such as A4, letter, and documentclass (article, book, report), etc. To modify page margins, there are several options, one of the easiest is to use the fullpage package.

This package sets the body of the page, which can make the body almost fill the entire page.

—— FULLPAGE PACKAGE DOCUMENTATION

Another option is to use the geometry package. Before exploring how the geometry package manipulates page margins, first look at the page dimensions shown below.

  1. 1 inch + \hoffset
  2. 1 inch + \voffset
  3. \oddsidemargin< /code>= 31pt
  4. \topmargin= 20pt
  5. \headheight= 12pt
  6. \headsep= 25pt
  7. \textheight= 592pt
  8. \textwidth= 390pt
  9. < li>\marginparsep= 35pt
  10. \marginparwidth= 35pt
  11. \footskip= 30pt< /li>

To set a margin of 1 inch using the geometry package, use the following example

\usepackage{geometry}\geometry{a4paper, margin=1in}

In addition to the above examples, the geometry command can modify paper size and orientation. To change the paper size, use the following example:

\usepackage[a4paper, total={7in, 8in}]{geometry}

To change the page orientation, landscape (landscape) needs to be added to the geometry options, like this:

\usepackage{geometry}\geometry{a4paper, landscape, margin=1.5in

Table of Contents

By default, the title of the directory is "contents". Sometimes, you want to change the heading to "Table of Content", change the vertical spacing between the table of contents and the first section of a chapter, or just change the color of the text.

To change the text, add the following line in the preamble, replacing English (english) with the desired language:

\usepackage[english]{babel}\addto\captionsenglish{\renewcommand{\contentsname}{\bfseries{Table of Contents}}}

To manipulate the virtual spacing between the table of contents and lists of figures, subsections and chapters, use the tocloft package. The two options used in this article are cftbeforesecskip and cftaftertoctitleskip.

The tocloft package provides methods for controlling the typography of tables of contents, lists of figures, and lists of tables.

——TOCLOFT PACKAGE DOUCMENTATION

\usepackage{tocloft}\setlength\ctfbeforesecskip{2pt}\setlength\cftaftertoctitleskip{30pt}

default directory

custom directory

Border

When using the package hyperref in a document, LaTeX chapter listings in the table of contents and citations containing \url have borders, as shown in the image below.

To remove these borders, include the following in the preamble and you will see that there are no borders in the table of contents.

\usepackage{hyperref}\hypersetup{pdfborder = {0 0 0}}

To modify the font, style or color of the title section, use the package titlesec. In this example, you will change the font size, font style, and font color of sections, subsections, and third-level subsections. First, add the following content in the preamble.

\usepackage{titlesec}\titleformat*{\section}{\Huge\bfseries\color{darkblue}}\titleformat*{\subsection}{\huge\bfseries\color{darkblue}}\titleformat* {\subsubsection}{\Large\bfseries\color{darkblue}}

Taking a closer look at the code, \titleformat*{\section} specifies the depth of the section to use. The example above uses up to the third depth. The {\Huge\bfseries\color{darkblue}} section specifies the font size, font style, and font color.

Page style

For custom headers and footers, use fancyhdr. This example uses this package to modify page styles, headers and footers. The code below briefly describes what each option does.

\pagestyle{fancy} %for header to be on each page\fancyhead[L]{} %keep left header blank\fancyhead[C]{} %keep center header blank\fancyhead[R]{\ leftmark} %add the section/chapter to the header right\fancyfoot[L]{Static Content} %add static test to the left footer\fancyfoot[C]{} %keep center footer blank\fancyfoot[R]{\thepage} %add the page number to the right footer\setlength\voffset{-0.25in} %space between page border and header (1in + space)\setlength\headheight{12pt} %height of the actual header.\setlength\headsep{25pt } %separation between header and text.\renewcommand{\headrulewidth}{2pt} % add header horizontal line\renewcommand{\footrulewidth}{1pt} % add footer horizontal line

The result looks like this:

Header

footer

Tips

Focus on the introduction area

If you are writing many TeX documents, you can create a .tex file containing all the preambles according to the document category and refer to this file. For example, I use the structure .tex as shown below.

$ cat article_structure.tex\usepackage[english]{babel}\addto\captionsenglish{\renewcommand{\contentsname}{\bfseries{\color{darkblue}Table of Contents}}} % Relable the contents% \usepackage[margin=0.5in]{geometry} % specifies the margin of the document\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}\usepackage{graphicx} % allows you to add graphics to the document\usepackage {hyperref} % permits redirection of URL from a PDF document\usepackage{fullpage} % formate the content to utilize the full page%\usepackage{a4wide}\usepackage[export]{adjustbox} % to force image position%\usepackage[section ]{placeins} % to have multiple images in a figure\usepackage{tabularx} % for wrapping text in a table%\usepackage{rotating}\usepackage{multirow}\usepackage{subcaption} % to have multiple images in a figure%\ usepackage{smartdiagram} % initialize smart diagrams\usepackage{enumitem} % to manage the spacing between lists and enumeration\usepackage{fancyhdr} %, graphicx} %for header to be on each page\pagestyle{fancy} %for header to be on each page%\fancyhf{}\fancyhead[L]{}\fancyhead[C]{}\fancyhead[R]{\leftmark}\fancyfoot[L]{Static Content} %\includegraphics[width=0.02\textwidth]{ virgin_voyages.png}}\fancyfoot[C]{} % clear center\fancyfoot[R]{\thepage}\setlength\voffset{-0.25in} %Space between page border and header (1in + space)\setlength\headheight{ 12pt} %Height of the actual header.\setlength\headsep{25pt} %Separation between header and text.\renewcommand{\headrulewidth}{2pt} % adds horizontal line\renewcommand{\footrulewidth}{1pt} % add horizontal line ( footer)%\renewcommand{\oddsidemargin}{2pt} % adjust the margin spacing%\renewcommand{\pagenumbering}{roman} % change the numbering style%\renewcommand{\hoffset}{20pt}%\usepackage{color}\usepackage [table]{xcolor}\hypersetup{ pdfborder = {0 0 0}} % removes the red boarder from the table of content%\usepackage{wasysym} %add checkbox%\newcommand\insq[1]{%% \Square\ #1\quad%%} % specify the command to add checkbox%\usepackage{xcolor}%\usepackage{colortbl}%\definecolor{Gray}{gray}{0.9} % create new colour%\definecolor{LightCyan}{rgb }{0.88,1,1} % create new colour%\usepackage[first=0,last=9]{lcg}%\newcommand{\ra}{\rand0.\arabic{rand}}%\newcolumntype{g} {>{\columncolor{LightCyan}}c} % create new column type g%\usesmartdiagramlibrary{additions}%\setcounter{figure}{0}\setcounter{secnumdepth}{0} % sections are level 1\usepackage{csquotes } % the proper was of using double quotes%\usepackage{draftwatermark} % Enable watermark%\SetWatermarkText{DRAFT} % Specify watermark text%\SetWatermarkScale{5} % Toggle watermark size\usepackage{listings} % add code blocks\usepackage{ titlesec} % Manipulate section/subsection\titleformat{\section}{\Huge\bfseries\color{darkblue}} % update sections to bold with the color blue \titleformat{\subsection}{\huge\bfseries\color{darkblue}} % update subsections to bold with the color blue\titleformat*{\subsubsection}{\Large\bfseries\color{darkblue}} % update subsections to bold with the color blue\usepackage[toc]{appendix} % Include appendix in TOC\ usepackage{xcolor}\usepackage{tocloft} % For manipulating Table of Content virtual spacing%\setlength\cftparskip{-2pt}\setlength\cftbeforesecskip{2pt} %spacing between the sections\setlength\cftaftertoctitleskip{30pt} % space between the first section and the text ``Table of Contents''\definecolor{navyblue}{rgb}{0.0,0.0,0.5}\definecolor{zaffre}{rgb}{0.0, 0.08, 0.66}\definecolor{white}{rgb}{ 1.0, 1.0, 1.0}\definecolor{darkblue}{rgb}{0.0, 0.2, 0.6}\definecolor{darkgray}{rgb}{0.66, 0.66, 0.66}\definecolor{lightgray}{rgb}{0.83, 0.83, 0.83 }%\pagenumbering{roman}

In your text, refer to the structure.tex file as shown in the following example:

\documentclass[a4paper,11pt]{article}\input{/path_to_structure.tex}}\begin{document}......\end{document}

Add watermark

To enable watermarks in LaTeX documents, use the draftwatermark package. The code snippet and image below demonstrate how to add a watermark to a document. By default, the watermark color is gray, which can be modified to your desired color.

\usepackage{draftwatermark} \SetWatermarkText{\color{red}Classified} %add watermark text \SetWatermarkScale{4} %specify the size of the text

Conclusion

In this series, you've learned about some of the basic but rich features LaTeX provides that can be used to customize a document to suit your needs or the audience you want it to be presented to. In the LaTeX ocean, there are still many packages that you need to explore by yourself.

via: https://fedoramazine.org/latex-typesetting-part-3-formatting/

Author: Earl Ramirez Title: Chao-zhi Translator: Chao-zhi Proofreading: wxy

This article was originally compiled by LCTT, and honored by Linux China

Articles are uploaded by users and are for non-commercial browsing only. Posted by: Lomu, please indicate the source: https://www.daogebangong.com/en/articles/detail/LaTeX%20Typesetting%203%20Typesetting.html

Like (810)
Reward 支付宝扫一扫 支付宝扫一扫
single-end

Related Suggestion