这是我之前(也许不必要地复杂)的问题的更新版本:
\documentclass[10pt]{article}
\usepackage[english]{babel}
\usepackage[paperwidth=6in,paperheight=9in, margin=1in]{geometry}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\newenvironment{customminipage}
{\begin{minipage}[t]{3in}}
{\end{minipage}\par\addvspace{6ex}\ignorespacesafterend}
\newcommand{\mynewcommand}[3]{
{\begin{customminipage}#1\end{customminipage}}
{\begin{customminipage}#2\end{customminipage}}
{\begin{customminipage}#3\end{customminipage}}
}
\begin{document}
Some text
\mynewcommand
{}
{}
{Argument 3}
Some text
\end{document}
生成:
我应该怎么做(也许minipage
方法不是最佳方法)来防止空参数的垂直间距?
答案1
在使用强力环境之前,请先使用\notblank{#1}{true branch}{false branch}
frometoolbox
测试空参数,minipage
无论是否要插入某些文本,都会添加垂直空间。
\documentclass[10pt]{article}
\usepackage[english]{babel}
\usepackage[paperwidth=6in,paperheight=9in, margin=1in]{geometry}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\usepackage[latin9]{inputenc}
\newenvironment{customminipage}
{\begin{minipage}[t]{3in}}
{\end{minipage}\par\addvspace{6ex}\ignorespacesafterend}
\newcommand{\mynewcommand}[3]{%
\notblank{#1}{\begin{customminipage}#1\end{customminipage}}{}%
\notblank{#2}{\begin{customminipage}#2\end{customminipage}}{}%
\notblank{#3}{\begin{customminipage}#3\end{customminipage}}{}%
}
\begin{document}
Some text
\mynewcommand
{}
{}
{Argument 3}
\mynewcommand
{And now}
{for something completely different}
{Argument 3}
Some text
\end{document}