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.

I'm trying to TeX a fairly long line of text:

\exists C\forall f(f\in C\Leftrightarrow f\in\ms{F}\wedge (\forall x\forall y)((x\in\dom f\wedge y\in\dom f\Rightarrow x=y)\wedge(\forall z)(z\in\dom f\Rightarrow \op{z}{z}\in f))).

The problem is, when I build, the line spills a little bit into the right margin. I don't mind terribly much, as the whole line fits, but is it possible to center the line so that is spills equally over in the left and right margins? I don't really want to split this formula among two lines.

If it's helpful, my preamble is:

\documentclass[11pt]{article}
\input{other/packages.tex}
\input{other/theoremdef.tex}

where packages.tex is

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amscd}
\usepackage{url}
\usepackage[top=1.3in, bottom=1.3in, left=1.3in, right=1.3in]{geometry}

% header and footer
\pagestyle{headings}

\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{stackrel}
\usepackage{mathrsfs}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{xy}
\input xy
\xyoption{all}

And theoremdef.tex is:

\newtheorem{exercise}{\bf Exercise}
\newcommand{\dom}{\text{dom}\ }
\newcommand{\ran}{\text{ran}\ }
\newcommand{\fld}{\text{fld}\ }
\newcommand{\op}[2]{\langle #1,#2\rangle}
\newcommand{\ot}[3]{\langle #1,#2,#3\rangle}
\newcommand{\ms}[1]{\mathscr{#1}}

Thanks.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

To resize long line you, possibly, may want to do that like this:

\newbox\formBox

\def\forMULA#1{%
  \setbox\formBox=\hbox{#1}%
    \centerline{%
      \ifdim\wd\formBox>\linewidth%
        \resizebox{\linewidth}{!}{#1}%
      \else%
        #1%
      \fi}}

\forMULA{$\exists C\forall f(f\in C\Leftrightarrow f\in\ms{F}\wedge (\forall x\forall y)((x\in\dom f\wedge y\in\dom f\Rightarrow x=y)\wedge(\forall z)(z\in\dom f\Rightarrow \op{z}{z}\in f))).$}

This inserts (for testing purpose) your formula into a box and tests if this box's dimension exceeds \linewidth. If so, scales it to fit. If not, inserts unscaled.

\centerline is used to prevent \parindent (you may want to use \noindent instead --- if you don't need the content to be centered).

You also need to \usepackage{graphicx} --- to have \resizebox available.

But if you want to center long line (to fly out over margins equally) you may use the following:

\newbox\formBox
\newskip\formSkip

\def\forMULAE#1{%
  \setbox\formBox=\hbox{#1}%
  \centerline{%
  \ifdim\wd\formBox>\linewidth%
    \setlength{\formSkip}{{\wd\formBox - \linewidth}/2}%
    \begingroup\leftskip=-\formSkip #1\endgroup%
  \else%
    #1% 
  \fi}}

This requires to \usepackage{calc} also.

share|improve this answer
    
Thanks brownian, I just got around to putting this in, and it worked beautifully. –  yunone Dec 31 '10 at 4:17
add comment

try this, if it is not too small: \resizebox{\linewidth}{!}{$ ...formula ...}

share|improve this answer
    
Thanks Herbert. –  yunone Dec 31 '10 at 4:23
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.