惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

XeTeX and LaTeX

Author per chapter (a.k.a. Proceedings) Subscript and superscript in text mode Typesetting tilde or backslash First gloss line in italics (gb4e) Table lines starting with square bracket Filetype recognition in Vim Vim for XeTeX/LaTeX First word of a paragraph Tables Block comment Line spacing in tables Assign another catcode Verbatim text as command argument Newcommand with an optional argument LaTeX’s new era started: XeTeX
Phantomas command
noreply@blogger.com (Anonymous) · 2009-05-20 · via XeTeX and LaTeX

Recently I have found that there is a useful TeX command \phantom{Phantom Text} which behaves just like it would typeset its argument except that nothing is typeset and there is a blank space of the corresponding dimensions.

When I have been using it I imagined it would be sometimes even more useful to have a command which can put some other stuff in the reserved space instead of the phantom stuff.

Luckily, some smart guys have already written such a command.

Here is a modified version of their minimal example which illustrates nicely the use of this command:


\documentclass{article}
\usepackage{calc} % for the \phantomas command

% The following command is a better version of \phantom and requires the "calc" package
% Credits: Jean-Côme Charpentier & Scott Pakin
% Source: comp.text.tex, "Phantom-ish command"
% usage: \phantomas[l]{phantom words which will be overwritten}{with these words}
% the optional parameter [l] says that the words "with these words" will appear aligned left to the reserved space
% another optional parameter is [r] for aligning the words right
% if no optional parameter is given, the words will be centred in the reserved space
\newcommand*\phantomas[3][c]{%
\ifmmode
\makebox[\widthof{$#2$}][#1]{$#3$}%
\else
\makebox[\widthof{#2}][#1]{#3}%
\fi
}

\begin{document}

A long entry another long entry and our last long entry\par
\phantomas{A long entry}{centred} \phantomas[l]{another long entry}{on the left}
\phantomas[r]{and our last long entry}{on the right}

$\sin^2 x + \cos^2 x = 1$\par
$\phantomas{\sin^2 x + \cos^2 x}{f(x)} = 1$\par
$\phantomas[l]{\sin^2 x + \cos^2 x}{f(x)} = 1$\par
$\phantomas[r]{\sin^2 x + \cos^2 x}{f(x)} = 1$

\end{document}