Graphics, Figures & TablesIndent tabular without using float

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Indent tabular without using float

Post by Singularity »

How do I indent a tabular, not center it, simply and easily, without using any float environments. Everything I read says to use some type of float environment, but the table must appear right where I put it (it's part of a test question) and not at the top or bottom of some future page. Following is an MWE.

Code: Select all

\documentclass[fleqn,addpoints
,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools}
%\usepackage{enumerate}			% Can't be used at the same time as enumitem
\usepackage{enumitem}				% Adds fancy labels for lists
\usepackage{color}					% Necessary for \shaded solutions and color solutions
\usepackage{coordsys}
\usepackage{polynom}
\usepackage{nicefrac}
\usepackage{commath}				% Calculus operators \od, \pd, etc.

\usepackage{array}					% Provides for a more flexible array and tabular environment
\usepackage{booktabs}				% For fancy stuff in arrays and tables, like the following column definitions
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%

\everymath{\displaystyle}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\shadedsolutions

% For the exam package
\newcommand{\q}{\question[1]}
\newcommand{\ch}{\choice}
\newcommand{\cc}{\correctchoice}
\newcommand{\al}{\answerline}
\setlength\answerclearance{0.4ex}
\CorrectChoiceEmphasis{\itshape\color{red}}

\begin{document}

\begin{questions}

\q Use the given data to construct a frequency distribution:\newline
A school district performed a study to find the main causes leading to its students
dropping out of school. Thirty cases were analyzed, and a primary cause was assigned to
each case. The causes included unexcused absences (U), illness (I), family problems (F),
and other causes (O). The results for the thirty cases are listed below:

\begin{tabular}{cccccccccc}
	U & U & U & I & F & O & O & U & I & F \\
	F & O & U & I & I & F & I & I & O & U \\
	I & F & F & U & U & I & I & O & F & U
\end{tabular}

Construct a table summarizing the frequency distribution of the primary causes leading to
student dropout.

\end{questions}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Indent tabular without using float

Post by Johannes_B »

Hi, i didn't compile your example. I first want to know what you mean by indent. Can you make it a bit clearer?

Remember, you can always add some horizontal space using \hspace{4cm} just in front of \begin{tabular}.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Indent tabular without using float

Post by Singularity »

By "indent" I meant I want the whole table moved maybe a half inch, or a full inch, to the right.

I tried \hspace{.5in}, \hspace{1in}, and \hspace{4cm} right before the \begin{tabular}, but the table did not move.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Indent tabular without using float

Post by Johannes_B »

Well ...

Code: Select all

\documentclass[fleqn,addpoints
	,answers
]{exam}
\usepackage{amsfonts,amsmath,amssymb,amsthm,mathtools}
    %\usepackage{enumerate}                 % Can't be used at the same time as enumitem
\usepackage{enumitem}                           % Adds fancy labels for lists
\usepackage{color}                                      % Necessary for \shaded solutions and color solutions
\usepackage{coordsys}
\usepackage{polynom}
\usepackage{nicefrac}
\usepackage{commath}                            % Calculus operators \od, \pd, etc.

\usepackage{array}                                      % Provides for a more flexible array and tabular environment
\usepackage{booktabs}                           % For fancy stuff in arrays and tables, like the following column definitions
\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%

\everymath{\displaystyle}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\shadedsolutions

    % For the exam package
\newcommand{\q}{\question[1]}
\newcommand{\ch}{\choice}
\newcommand{\cc}{\correctchoice}
\newcommand{\al}{\answerline}
\setlength\answerclearance{0.4ex}
\CorrectChoiceEmphasis{\itshape\color{red}}

\begin{document}

\begin{questions}

	\q Use the given data to construct a frequency distribution:\newline
	A school district performed a study to find the main causes leading to its students
	dropping out of school. Thirty cases were analyzed, and a primary cause was assigned to
	each case. The causes included unexcused absences (U), illness (I), family problems (F),
	and other causes (O). The results for the thirty cases are listed below:

\hspace{.5in}%
\begin{tabular}{cccccccccc}
	U & U & U & I & F & O & O & U & I & F \\
	F & O & U & I & I & F & I & I & O & U \\
	I & F & F & U & U & I & I & O & F & U
\end{tabular}

	Construct a table summarizing the frequency distribution of the primary causes leading to
	student dropout.

\end{questions}
\end{document}
Hint: Click on »open in writelatex« just above the code to see the output.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Re: Indent tabular without using float

Post by Singularity »

I tried that earlier and it didn't work. I guess I was making some other mistake, which is now gone. TY.
Post Reply