Document Classesenumerate with horizontal align

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

enumerate with horizontal align

Post by bkarpuz »

Dear LC members,

I spent more than a hour for searching how to align items horizontally instead of vertically, but I could not find any examples.
Would you please help me having a list as follows?

1. Item 1....2. Item 2....3. Item 3

Thanks a lot.
bkarpuz
Last edited by bkarpuz on Sat Mar 26, 2011 1:28 am, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

enumerate with horizontal align

Post by Stefan Kottwitz »

Hi bkarpuz,

you could use the paralist package and the inparaenum environment.

Stefan
LaTeX.org admin
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

enumerate with horizontal align

Post by bkarpuz »

Thanks Stefan_K, but I still need help.

I use the following preamble.

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\usepackage{paralist}
\usepackage{enumitem}
When I use enumerate for my questions as follows

Code: Select all

\textbf{Questions}.
\begin{enumerate}[label={(\alph*)},leftmargin=*,ref=(\alph*)]
\item\label{q1a} Question~1.
\item\label{q1b} Question~2.
\end{enumerate}
I can refer those items in answers in itemize as follows

Code: Select all

\textbf{Answers}.
\begin{itemize}
\item[\ref{q1a}] Answer~1.
\item[\ref{q1b}] Answer~2.
\end{itemize}
But when I use inparaenum instead of enumerate as follows,
I dont get the same output in answers.

Code: Select all

\textbf{Questions}.
\begin{inparaenum}[(a)]
\item\label{q1a} Question~1. \item\label{q1b} Question~2.
\end{inparaenum}
Is it possible to fix it?

Moreover, the distance between '(a)' and 'Question 1' when inparaenum is used is not the same as enumerate gives.

Thanks.
bkarpuz
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

enumerate with horizontal align

Post by Stefan Kottwitz »

You could simply write (\ref{...}) with your own parentheses. The paralist documentation does that.

Regarding the distance: those packages use different distances. Instead of programming, you could also simply write

Code: Select all

\begin{inparaenum}[(a)~] ...
or use another spacing command instead of ~.

Stefan
LaTeX.org admin
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

enumerate with horizontal align

Post by bkarpuz »

Stefan_K wrote:You could simply write (\ref{...}) with your own parentheses. The paralist documentation does that.
Since I also use hyperref they exactly differ from each other in the output.
Is there another way for this to look them identically same as enumerate generated items?
Stefan_K wrote: Regarding the distance: those packages use different distances. Instead of programming, you could also simply write

Code: Select all

\begin{inparaenum}[(a)~] ...
or use another spacing command instead of ~.
Thanks this works very well.

Your help is really appreciated.
bkarpuz
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

enumerate with horizontal align

Post by Stefan Kottwitz »

You didn't mention hyperref before., ;-)
Ok, here's another way:

Code: Select all

\documentclass{article}
\usepackage{paralist}
\usepackage{hyperref}
\renewcommand*{\theenumi}{(\alph{enumi})}
\renewcommand*{\labelenumi}{\theenumi~}
\begin{document}
\textbf{Questions}.
\begin{inparaenum}
\item\label{q1a} Question~1. \item\label{q1b} Question~2.
\end{inparaenum}

\textbf{Answers}.
\begin{itemize}
\item[\ref{q1a}] Answer~1.
\item[\ref{q1b}] Answer~2.
\end{itemize}
\end{document}
Stefan
LaTeX.org admin
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

enumerate with horizontal align

Post by bkarpuz »

Stefan_K wrote:You didn't mention hyperref before., ;-)
Ok, here's another way:

Code: Select all

\documentclass{article}
\usepackage{paralist}
\usepackage{hyperref}
\renewcommand*{\theenumi}{(\alph{enumi})}
\renewcommand*{\labelenumi}{\theenumi~}
\begin{document}
\textbf{Questions}.
\begin{inparaenum}
\item\label{q1a} Question~1. \item\label{q1b} Question~2.
\end{inparaenum}

\textbf{Answers}.
\begin{itemize}
\item[\ref{q1a}] Answer~1.
\item[\ref{q1b}] Answer~2.
\end{itemize}
\end{document}
Stefan
This is awesome!

Thanks a lot Stefan.
bkarpuz
Post Reply