I have a custom minipage
environment that may have 2 different width values with the same basic setup. I create a \newcommand
that stores which width to use when. These minipage
s go into a tabular*
environment and a bunch of other stuff is done. However, I've isolate my issue in the following example.
\newcommand{\MinipageTableSizeLookup}[1]{
\ifnum #1 = 3 {0.279}
\else {0.359}
\fi
}
\newenvironment{MyMiniPage}[4]{
\begin{minipage}[t]{ 0.279\linewidth}
\begin{center} \textbf{#2 (#3)} \newline \textit{#4} \end{center}
}{
\end{minipage}
}
When calling
\begin{MyMiniPage}{3}{Some Header}{14}{Subheading}
This is useful information setup in this way.
\end{MyMiniPage}
succeeds only if the plain text of 0.279\linewidth is entered in the \begin{minipage}[t]{ 0.279\linewidth}
. Swapping that out with \MinipageTableSizeLookup{#1}
fails with error "Missing number, treated as zero." I want to be able to toggle on the fly the width of these minitable
s when called.
I've tried including \linewidth
in the \MinipageTableSizeLookup
command.
Here's my preamble for reference:
% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{a4paper}
\geometry{margin=0.50in}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{paralist}
\usepackage{verbatim}
\usepackage{fancyhdr}
\usepackage[table]{xcolor}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}
\usepackage{sectsty}
\allsectionsfont{\sffamily\mdseries\upshape}
Best Answer
You need
0.3\linewidth
not{0.3}\linewidth
so you need to drop the braces from your\ifnum