2

I want to reverse (flip horizontal) all columns in some tables like this:

\documentclass{book}‎
‎\begin{document}‎
\begin{center}‎
‎\begin{tabular}{c|c|c}‎
‎$p$ & $q$ & $p\vee q$ \\ \hline‎
‎$T$ & $T$ &T\\‎
‎$T$ & $F$ &T\\‎
‎$F$ & $T$ &T\\‎
‎$F$ & $F$ &F‎  
‎\end{tabular}‎
‎\end{center}‎
‎\end{document}

I wrote these tables in Persian Xe-TeX and this language is a right to left writing language, and these tables appear reverse in output, so I used \lr command but the tables broke down and went out from centering also. I don't want to rewrite them. How can I fix it?

3
  • Please clarify what you mean by "reverse (flip horizontal)". E.g., do you want to invert the ordering of the columns?
    – Mico
    Jun 30, 2016 at 18:49
  • @Mico I want to the first column appears in the last position and second goes to column-1 and so on, then the last column will be the first of new table.
    – Nosrati
    Jun 30, 2016 at 19:16
  • I think your best best is to use an editor that lets you select rectangular blocks and cut and paste them as you see fit.
    – Mico
    Jun 30, 2016 at 19:47

1 Answer 1

4

Edit:

If we want reversed order, an exemplary solution for three columns may be as follows:

\documentclass{book}

\begin{document}
\begin{center}

Original

\begin{tabular}{c|c|c}
$p$ & $q$ & $p\vee q$ \\ \hline
$T$ & $T$ &T\\
$T$ & $F$ &T\\
$F$ & $T$ &T\\
$F$ & $F$ &F  
\end{tabular}

Reversed order

\def\1#1&#2&#3\\{#3 &#2 &#1 \\}

\begin{tabular}{c|c|c}
\1$p$ & $q$ & $p\vee q$ \\ \hline
\1$T$ & $T$ &T\\
\1$T$ & $F$ &T\\
\1$F$ & $T$ &T\\
\1$F$ & $F$ &F\\ %this one added - PS  
\end{tabular}

\end{center}
\end{document}

enter image description here

5
  • Thanks, but what should I do with these mirrored characters?
    – Nosrati
    Jun 30, 2016 at 19:25
  • @S.Nosrati There are at least 3 possible interpetations of your request. This one is the simplest one to obtain. But after some clarifying a different combination of reversing the order and entries in columns is possible. Jun 30, 2016 at 19:33
  • It's great. This works for moving every arbitrary column without rewrite it. OK. Thanks a lot.
    – Nosrati
    Jun 30, 2016 at 20:33
  • Another question that can we delete an arbitrary column in this flapping! process? For example the original table has 10 columns and with this definition they reduce to 8 columns?
    – Nosrati
    Jun 30, 2016 at 20:40
  • @S.Nosrati Yes, it is possible. However rather precise formulation of the problem would help. In particular, reducing from 9 to 7 columns is easier than from 10 to 8. BTW: I think, that removing the first part of my answer is a good move, but if for some reasons you want it to stay, it will stay. Jun 30, 2016 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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