• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

simonharrer/latex-best-practices: LaTeX Best Practices

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

simonharrer/latex-best-practices

开源软件地址(OpenSource Url):

https://github.com/simonharrer/latex-best-practices

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

LaTeX Best Practices

At the very beginning

\RequirePackage[l2tabu, orthodox]{nag} % detect deprecated use of latex packages and commands

During writing

\usepackage[notref,notcite]{showkeys} % useful when writing the paper

Commands to find issues faster

\overfullrule=2cm % allows to find overfull hboxes much quicker

figures only appear after their first use, never ever before

\usepackage{flafter} 

Inspirational Quotes

% import
\usepackage{epigraph}

% use
\chapter{Background}
% optionally, use \epigraphhead[30]{\epigraph...} to put the epigraph above the chapter name
\epigraph{If I have seen further, it is by standing on the shoulders of giants.}{\emph{Isaac Newton}}

Custom Counters and References

% commands
\newcounter{requirement}% create counter <requirement> with <0> as initial value
\renewcommand*\therequirement{R\arabic{requirement}}% ensure that the counter is always printed as R<requirement>
\newcommand{\requirement}{%
(%
\refstepcounter{requirement}% <requirement> = <requirement> + <1>
\therequirement% print R<requirement>
)%
}

% usage
\requirement\label{req:fast-tests} % (R1)
\requirement\label{req:make-world-a-better-place} % (R2)

\ref{req:fast-tests} % R1
\ref{req:make-world-a-better-place} % R2

I could have created the label as part of the macro, but then, most LaTeX editors will not be able to code complete these labels as they cannot determine that any passed parameters are labels. Moreover, textools can detect these labels and check whether they are unused.

Tables

% import
\usepackage{booktabs}

% use
\begin{tabular}{rl}
	\toprule
	\textbf{name} & \textbf{version} \\ 
	\midrule
	tool A & 1.0\\
	tool B & 5.3\\
	tool C & 4.0\\
	\bottomrule
\end{tabular}

Packages which simply help always

\usepackage{warning} % for warning messages
\usepackage{refcheck} % show unused labels
\usepackage{strict} % check for not using undefined environments

\usepackage{microtype} % nicer output
\usepackage{hfoldsty} % nicer output
\usepackage{lmodern} % use the modern fonts
\usepackage{charter} % use the charter font

\usepackage[ngerman,USenglish]{babel} % language selection
\usepackage[T1]{fontenc} % western languages encoding
\usepackage[utf8]{inputenc} % set encoding to UTF-8

TODOs

% import
\usepackage{todonotes}

% usage
\todo{TODO as a margin block}
\todo[inline]{TODO within the text}
\missingfigure{Description of missing figure}

\listoftodos

URLs and references

\usepackage[hyphens]{url} % detection of urls
\usepackage{hyperref} % should be imported after all other packages as it changes a lot
\usepackage[all]{hypcap} % Adjusting the anchors of captions
\usepackage[hyperpageref]{backref} % add backlinks from the references to the cited pages
\usepackage[capitalise,nameinlink]{cleveref} % always prepend the correct type before each reference

Quotations

\usepackage[strict=true,english=american]{csquotes}

Acroynms

% import
\usepackage[printonlyused,withpage]{acronym}

% usage list
\begin{acronym}
  \acro{API}{Application Programming Interface}
\end{acronym}

% usage in text
\ac{API} % API, show full if first use
\acf{API} % always Application Programming Interface (API)
\acp{API} % APIs, show full if first use
\acfp{API} % always Application Programming Interfaces (APIs)
\acs{API} % always API

Keywords besides paragraph

% import
\usepackage{marginnote} % notes on the margin of the page

% ensures this is always correctly aligned
% see http://tex.stackexchange.com/questions/16141/align-marginpar-with-beginning-of-paragraph
\let\brokenmarginnote\marginnote
\renewcommand{\marginnote}[1]{\hspace{0pt}\brokenmarginnote{#1}}

% use footnotesize as a font size to push the margin notes into the background
\renewcommand{\marginnote}[1]{\hspace{0pt}\brokenmarginnote{{\footnotesize #1}}}

% usage
\marginnote{This is put right next to the paragraph}

Special Commands

% user stories
\newcommand{\userstory}[3]{\textbf{As a} #1, \textbf{I want to} #2 \textbf{so that I can} #3.}

% describing XML elements, attributes, and values of attributes
\newcommand{\xml}[1]{\texttt{<#1>}} % <element> in typewriter
\newcommand{\attr}[1]{\texttt{@#1}} % @attribute in typewriter
\newcommand{\attrval}[2]{\texttt{#1}=\val{#2}} % attribute="value" in typewriter (only equals sign is normal)
\newcommand{\val}[1]{\texttt{"#1"}} % "value" in typewriter

Space Saving Techniques

Use Times Instead

\usepackage{mathptmx}

Smaller Font Size for References

{\footnotesize
\bibliography{bibfile}}

Remove Space Between Bibliography Entries

% saves almost half a page by removing space between references
\let\oldbibliography\thebibliography \renewcommand{\thebibliography}[1]{%
   \oldbibliography{#1}%
   \setlength{\itemsep}{0pt}%
}

Shorten a paragraph

% import
\usepackage{microtype}
\SetExpansion
[ context = sloppy,
stretch = 30,
shrink = 36,
step = 1 ]
{ encoding = {OT1,T1,TS1} }
{ }
%source: http://tex.stackexchange.com/a/280936/9075

% use
{\microtypecontext{expansion=sloppy}
This text shrinks a bit more to help saving a line if only one word is put in the last line of the paragraph.
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Chen-Jr/ICPC-Code-Template-in-Latex: This project is to create a ICPC Code Templ ...发布时间:2022-07-09
下一篇:
ArpitShukIa/KotlinWorkshop发布时间:2022-07-07
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap