Redefining an environment or a command with an indefinite numbers of items
According to LaTeX's basic commands if I want to create a list of items I have to use the following concept code:
\begin{itemize} \item first \item second \item third \end{itemize}
To keep my code as clean as possible and really customizable I use another concept:
\begin{myenv} \item first \item second \item third \end{myenv}
If it's possible, I'd like to also customize the "item command" like this (but it's not really essential):
\begin{myenv} \myitem first \myitem second \myitem third \end{myenv}
The problem is: How I can redefine an environment like this?
\newenvironment{myenv} {?} {?}
I'd like to ask the same question for the newly created command with
\newcommand{\mycmd}{?}
Replay
You could use the enumitem package to set up your own list.
Note that in the code below I have used \newlist to create the environment mylist and setlist to customize it. The {10} refers to the max-depth, which means that you could have at most 10 nested versions you are likely to have.
The enumitem package provides many more options for customizing the labels, indentation, margins, font, etc- see the documentation for more details.
\documentclass{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{10}
\setlist[mylist]{label=$\triangleright$}
\begin{document}
\begin{mylist}
\item my first item
\item my second item
\end{mylist}
\end{document}
Defining a new environment that matches the itemize environment is done in the following way:
Note that \item may take an optional argument, and it is therefore not as easy to merely "copy" it through \newcommand{\mycmd}{\item}. The letltxmacro package allows for making a "responsible" copy. Here is a minimal example that shows the usage:
\documentclass{article}
\newenvironment{myenv}%
{\begin{itemize}}% \begin{myenv}
{\end{itemize}}% \end{myenv}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\LetLtxMacro{\mycmd}{\item}% \mycmd = \item
\begin{document}
\begin{myenv}
\mycmd first
\mycmd second
\mycmd third
\end{myenv}
\end{document}
As mentioned above, you can now also use \mycmd[<stuff>] which will override the traditional \textbullet itemized bullet.
Recently me and some friends really got into "making everything compilable". More specifically, we need to do a lot of matlab calculations, and then we need to put the results into a tex document. I've had some time left recently and decided to
I want to redefine the quote environment in such a way to get the output of the following code. \begin{quote}{\tiny\textquotedblleft Text \textquotedblright}\end{quote} I also want to fix the line spacing because the distance between the lines looks
I want to redefine the pmatrix environment provided by the amsmath package (and changed by the mathtools package) for adding good-looking delimiters. The code is below: \documentclass{article} \usepackage{amsmath,mathtools,environ} \RenewEnviron{pmat
I am using Red Hat Linux Enterprise version 5. I've noticed people sometimes running commands with a couple of & options. For example, in the below command, there are two & signs. What is the purpose of them? Are they always used together with noh
How can you edit the environment variables via command line in ubuntu? --------------Solutions------------- You can set environment variables from the command line, but the new values will apply only to that terminal session and any processes launche
The Joel Test includes the question: Can you make a build in one step? Which is important, but I'm wondering, how streamlined have some of the deployment processes been? All software from shrink-wrap to web applies: what's the best deployment environ
I would like to execute a command with administrative privileges, but do not have an access to the tty. I tried to execute it with the -A option of the sudo command and setting the environment variable SUDO_ASKPASS=/usr/bin/gksu. To do the same I ran
How can I run multiple commands with PsExec, and how can I export environment variables? I can run two commands by doing the below, but when I try to export an environment variable the second command errors out. Running two commands: psexec \\servern
From How to add a program to a list with right click button?, I could add "command" button to open command line prompt using right click. I normally open the command line prompt to use Visual Studio tools, so running 'vcvarsall.bat' in the comma
Lua code environment I moved on to XeTeX (XeLaTeX) a while ago. I was using pdfLaTeX before that, but now I'm quite comfortable with XeLaTeX. Now, I'd like to use LuaLaTeX to embed Lua in some LaTeX documents. The doc states several ways to embed Lua
I know I have asked this before. But I just can not wrap my head around some things in LaTeX. Like the optional arguments. I have gotten some clues how to do it for comands, but not quite sure how to do it for commands. What I am looking for is putti
How can I run a cron command with existing environmental variables? If I am at a shell prompt I can type echo $ORACLE_HOME and get a path. This is one of my environmental variables that gets set in my ~/.profile. However, it seems that ~/.profile doe
I want to define an environment that read its content before processing (like \newEnviron from the package environ) but also that allows key-value parameters (like \newkeyenvironment from the package keycommand that I usually use). How should I do? -
As I am working on improving my answer to Different approach to literate programming for LaTeX, I have created a macro that automatically processes two arguments and formats indexes accordingly. The arguments are strings (not control sequences), with
Basically i want to get a record of all commands executed on my ssh server, with their times. The codes i have tried are : ssh [email protected] 'export HISTFILE=~/.bash_history; set -o history; history' I got all commands,but i dont get time stamps with this
Possible Duplicate: using history command with ssh and getting output with time stamps Basically i want to get a record of all commands executed on my ssh server, with their correct timestamps. The codes i have tried are : ssh -i private_key [email protected]
I would like to create new command with functionality like this (pseudo code): \newcommand{\myCommand}[numOfParameters] { for (i = 0; i < numOfParameters / 3; i++) { \somecommand1{#(i*3 + 1)} \somecommand1{#(i*3 + 2)} \somecommand1{#(i*3 + 3)} } } Is
The Problem There are several packages I would like to write which require me to redefine the \newcommand (\renewcommand, etc.) command so I can track or change the commands that authors subsequently define. But I have no idea how to go about it. My
In order to reduce copy-pasting, I want to create an environment that will produce a two-column table with headers and two listings in different languages, like below: \begin{tabular}{l l} Python & Haskell \\ \hline \\ \lstset{language=Python} \begin