Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the command \mpagetc defined as

\newcommandx*\mpagetc[4][1=0.45,2=0.45]{\begin{minipage}{\textheight}%
\begin{minipage}[c]{#1 \textwidth}% 
#3
\end{minipage}%
\begin{minipage}[t]{#2 \textwidth}% 
#4
\end{minipage}%
\end{minipage}}

I get the error Paragraph ended before \\mpagec was complete only when I have a blank line in the code,

\mpagetc{
blablabla

blablabla
}{ blablabla}

I have the same problems with other commands that does not allow blank lines. What is the problem with blank lines?

share|improve this question
add comment

2 Answers

If you're not strictly tied to xargs, I'd suggest xparse and a change of order in the optional arguments:

\usepackage{xparse}

\NewDocumentCommand{\mpagetc}{ O{0.45} +m O{0.45} +m }{%
  \begin{minipage}[t]{#1\textwidth}
  #2
  \end{minipage}%
  \begin{minipage}[c]{#3\textwidth}
  #4
  \end{minipage}%
}

so that you can set the two factors independently of each other

\mpagetc{A}{B}

\mpagetc[0.3]{A}{B}

\mpagetc{A}[0.4]{B}

\mpagetc[0.3]{A}[0.4]{B}

By specifying the mandatory arguments with +m they are “long”.

Complete example.

\documentclass{article}

% the following three lines are just for the example
\usepackage[latin]{babel}
\usepackage[margin=1cm]{geometry}
\usepackage{lipsum}

\usepackage{xparse}

\NewDocumentCommand{\mpagetc}{ O{0.45} +m O{0.45} +m }{%
  \begin{minipage}[t]{#1\textwidth}
  #2
  \end{minipage}%
  \begin{minipage}[c]{#3\textwidth}
  #4
  \end{minipage}%
}


\begin{document}
\mpagetc{
  \scriptsize\lipsum[2]

  End.
}{
  \scriptsize\lipsum[4]

  End.
}

\mpagetc[0.3]{
  \scriptsize\lipsum[2]

  End.
}{
  \scriptsize\lipsum[4]

  End.
}

\mpagetc{
  \scriptsize\lipsum[2]

  End.
}[0.3]{
  \scriptsize\lipsum[4]

  End.
}

\mpagetc[0.3]{
  \scriptsize\lipsum[2]

  End.
}[0.5]{
  \scriptsize\lipsum[4]

  End.
}
\end{document}

enter image description here

share|improve this answer
    
wow, I like this way! –  wmora2 Jan 22 at 13:41
add comment

Blank lines tantamount to \par; using the starred version \newcommandx* forbids \par inside the defined command. For "long" commands (i.e., admitting \par), you should use the un-starred version \newcommandx:

\documentclass{article}
\usepackage{xargs}

\newcommandx\mpagetc[4][1=0.45,2=0.45]{\begin{minipage}{\textheight}%
\begin{minipage}[c]{#1 \textwidth}% 
#3
\end{minipage}%
\begin{minipage}[t]{#2 \textwidth}% 
#4
\end{minipage}%
\end{minipage}}

\begin{document}

\mpagetc{a 

b}{c}

\end{document}

The same remark applies to standard (i.e., without xargs) \newcommand and \newcommand*.

share|improve this answer
    
Thanks, simple and basic! –  wmora2 Jan 22 at 13:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.